You are on page 1of 4

INTEGRATION OF JENKINS WITH TOMCAT

Step1: we need to install java 8


sudo apt-get install openjdk-8-jdk
Step2: sudo apt update
Step3: to check java version
java -version
Step4: we need to install git
sudo apt-get install git
Step5: to check git version
git --version
Step6: we need to configure in git
git config --global user.name "username"
git config --global user.email "emailID"
Step7: we need to create a directory for saving project and add to git
mkdir test
cd test(to change the directory)
Step8: we need to add files to github
git add .
Step9: to check whether all files are added or not
git status
Step10: we need to commit the project
git commit -m "first repo"
Step11: we need to add the code of the project from github
git remote add origin "passte the url of the repository"
Step12: git push origin main
12.1 we need to enter username
12.2 we need to enter password
12.2.1 go to my settings
12.2.2 go to developer settings
12.2.3 generate personal access token and copy the token to use it as
the password
Step13: we need to install maven
sudo apt install maven
Step14: to check the maven version
mvn -version
Step15: Install Java to Execute Jenkins war file.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt install openjdk-8-jdk
Step16: Now Install Jenkins on Machine
Add Key on Host
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key
add -
Step17: Add following entry in your /etc/apt/sources.list
echo deb http://pkg.jenkins-ci.org/debian binary/ >
/etc/apt/sources.list.d/jenkins.list
Step18: Update your local package index, then finally install Jenkins
sudo apt-get update
sudo apt-get install jenkins
Step19: open web browser and type
localhost:8080
Step20: now we get a path to get administration password for jenkins copy the path
and paste in terminal
sudo cat (path)
Step21: now create an account in jenkins
Step22: now open manage configurations
22.1 manage plugins
22.1.1 under avaiable plugins search for GITHUB INTEGRATION , DEPLOY
CONTAINERS , COPY ARTIFACTS and install without restart
22.2 global tool configuration
22.2.1 now add jvm path
22.2.1.1 name
22.2.1.2 path (/usr/lib/java/java-8-jdk/bin)(path can be
checked from terminal by first typing 1./usr/lib/java tab 2./usr/lib/java/java-8/
tab and add bin and change directory to java path to paste in jenkins)
22.2.2 now add git
22.2.2.1 name
22.2.2.1 path (either give git) or (the code of repository) or
(the url where the pom.xml file is saved) at last we need to give /pom.xml
22.2.3 now add maven
22.2.3.1 name
22.2.3.2 path (/usr/share/maven) when the path is shown red
then it is not correct
Step23: now create a new item
23.1 name of the file
23.2 click add readme and save
23.3 we need to give description
23.4 select git in source code management
23.5 copy the url from code in github and path near git repository
23.6 the branch from where we are integrating git to jenkins should be a
default branch in github
23.6.1 change the main to master default branch
23.6.1.1 go to settings
23.6.1.2 change the project branch as default
23.7 come down to build and select invoke top-level maven targets
23.7.1 set goals to CLEAN PACKAGE
23.7.2 click advanced in maven path
23.7.2.1 now enter the POM path from githut where the pom file
is save and after pasting the path write /pom.xml
23.8 come down to post-build actions
23.8.1 add archieve the artifacts
23.8.2 under files to archive write **/*.war
23.9 now click build now
23.9.1 check console output if it shows success build is done
perfectly and it is shown in GREEN color
23.9.2 if it shows console failure check the errors and solve and it
is shown in RED color
Step24: now we need to integrate and deploy jenkins with tomcat
Step25: we need to unzip and wgt files first
sudo apt install unzip wget
Step26: now change the directory to tmp
cd /tmp
Step27: now go to google and search for apache tomcat 8 and open the first url in
search
27.1 now scroll download under binary distributions
27.1.1 under core you will file a word with zip
27.1.1.1 now we need to right click on zip and copy the url
NOTE: don't right click on pgp or sha512 to copy the
url where it leads to failure of installation
27.2 now paste the link with wget
wget
http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-
8.5.47.zip
Step28: now unzip tomcat with the command mentioned below:
unzip apache-tomcat-8.5.47.zip
Step29: now make a directory
sudo mkdir -p /opt/tomcat
Step30: now copy the file
cp -rf /apache-tomcat-8.5.47 /opt/tomcat
Step31: now change tomcat server port
Go to the file below
/opt/tomcat/apache-tomcat-8.5.47/conf/nano server.xml
31.1 now it shows the vi page of server.xml
31.1.1 now scroll down to connector portion
31.1.2 now change the connector port value
31.1.3 press CTRL+X and press Y and press enter
Step32: now change the directory to bin
cd ../bin
Step33: to change the access mode of a file
chmod +x *
Step34: to start the tomcat service use the below command
cd /opt/tomcat/apache-tomcat-8.5.72/bin#./startup.sh
Step35: to Configure Jenkins with Tomcat for Auto Deployment of Artifacts
Set Credentials of Tomcat that Jenkins use
cd /opt/tomcat/apache-tomcat-8.5.47/conf
35.1 now we need to update the file
35.1.1 cd /opt/tomcat/apache-tomcat-8.5.47/conf#nano tomcat-users.xml
35.1.1.1 now it shows a vi page of tomcat-users.xml
35.1.1.2 now first uncomment the roles block
35.1.1.3 now update rolename1=manager-script
35.1.1.4 now update rolename2=manager-gui
35.1.1.5 now set username=" " and password=" "
35.1.1.6 now mentions the role=manager-script,manager-gui
35.1.1.7 press CTRL+X and press Y and press enter
Step36: now we need to comment the connector and value in META-INF
cd /opt/tomcat/apache-tomcat-8.5.47/webapps/manager/META_INF#nano
context.xml
36.1 now it shows the vi page of context.xml
36.1.1 now scroll down to find values
36.1.2 now comment the connection and value part <!-- -->
Step37: now shutdown the tomcat services to implement the changes
cd /opt/tomcat/apache-tomcat-8.5.72/bin#./shutdown.sh
Step38: now start the tomcat services
cd /opt/tomcat/apache-tomcat-8.5.72/bin#./startup.sh
Step39: go to web browser and type localhost:(the given port number) to check
whether apache tomcat is running or not
Step40: now open jenkins
40.1 new item
40.1.1 name
40.1.2 freestyle project
40.1.3 save
40.2 give description
40.3 accept Discard old builds
40.3.1 enter how many days to keep the builds
40.3.2 enter max # of builds to keep
40.4 source code management to be none
40.5 under build environment
40.5.1 accept delete workspace before build starts
40.5.2 add timestamps to the console output
40.6 under build options select copy artificats from another project
40.6.1 project name where the build of test and install is successfull
40.6.2 select stable build only
40.7 in post build select war/ear to a container
40.7.1 give **/*.war in WAR/EAR files
40.7.2 context path should be given /
40.8 now add containers
40.8.1 under credentials click add and give tomcat username and
password
40.8.2 now select the tomcat successed file
40.8.2 now enter the tomcat url with the ip address of yours
http://192.168.110.128:(tomcat port)
40.9 save
40.10 click build now
Step41: once the build is successfull now open the tomcat with localhost:(port)
Step42: output should display the following wait if the deployment is successfull
in jenkins of tomcat
Hello World! Welcome to Jenkins Training v2 Code Pipeline...

You might also like