0% found this document useful (0 votes)
24 views27 pages

Jenkins - Setup, Build - War, Deploy Aritifact To Sit & Automate The Jenkins Job

Uploaded by

nehatabassum4237
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views27 pages

Jenkins - Setup, Build - War, Deploy Aritifact To Sit & Automate The Jenkins Job

Uploaded by

nehatabassum4237
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 27

Launch the two instances on aws

Give the names to the instances

JENKINS SETUP:

Connect to dev machine through git bash

Update the apt repository


Sudo apt-get update

Download java

Sudo apt-get install -y openjdk-21-jdk

Open the bowser type jenkins.io in the url --> click on the
download
Right click on the generic java package --> copy the link

https://get.jenkins.io/war-stable/2.492.2/jenkins.war

Run the below command in the gitbash dev terminal

$wget https://get.jenkins.io/war-stable/2.492.2/jenkins.war

Start the jenkins

$java -jar jenkins.war

Administration password is available on the terminal

ACCESSING JENKINS:

Open the browser -->Take the public ip of devserver :8080

Copy paste the admin password


Click on install suggested plugin
Build war file:

Connect dev terminal through git

Check java is install or not. If not install then install java

Check maven is install or nto . if not install then install maven

Check jenkins is install or not . if not install then install jenkins


Maven download:

Go to the root directory

Sudo su -

Cd /opt

Open the browser type maven download

Right click on the apache-maven.3.9.9.bin.tar.gz -->copy the


link

Wget
https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-
maven-3.9.9-bin.tar.gz
Unzip the maven gip file

Tar -xvzf apache-maven-3.9.9-bin.tar.gz

#ll

Rename apache-maven-3.9.9 to maven

Cd maven

#ll
Note down the maven path
#pwd
/opt/maven

Move to cd bin

#ll

Note down the maven bin path (/opt/maven/bin)


#pwd

Now check the maven is install or not

Mvn --version

Try with the below command


./mvn --version
Now go back to the roor directory --> cd /

Check the maven version --> mvn --version

It shows maven is not found.

So we need to create environment variable

Go to root directory with below command

Cd ~

#ll

U can see the .profile file

Open the file with below command

Sudo vim .profile

Go to the insert mode( click on I) and give the maven,java home


and m2 paths here
:wq

To get the java_home path


#find / -name java-21* (/usr/lib/jvm/java-21-openjdk-amd64)

#echo $PATH

U CANT SEE THE JAVA AND MAVEN PATH ABVOE . SO


WE NEED TO RESTART THE .PROFILE FILE with below
command

#source .profile

Now u can see the java and maven paths

Now check the maven version

#mvn --version -->now u can able to see the maven


Now go to the jenkins dashboard u need to install one plugin
(maven integratin)

Managejenkins-->plugins-->available plugins-->maven
integration plugin

Without this plugin we can’t able to see the maven project

Once installed , click on the restart jenkins

U need to add java and maven paths in the jenkins

Go to jenkins dashboard-->managejenkins-->tools

Add JDK and add MAVEN


UNCHECK THE install automatically

Add maven

Click on apply and save it

Now we can create job for war file

Dashboard-->newitem-->war(give any name) select maven


project click on ok
Source code management-->select git--> give the github url
project path(open my github account-->go to the repositories
Select the practice repository)

Copy the HTTPS path paste it in the jenkins repository url


Select the build goal and options write the command clean
install click on apply and save

Click on build now

If job execution is taking lot of time


Then
logout the jenkins
Stop the dev instance
Restart the dev instanc
Start the jenkins server
Run the job
Now ur job will be excuted
Deploy artifcat into sit server

Connect to sit machine with git bash

Update the apt repository

Sudo apt-get update

Install tomcat 9
Sudo apt-get install -y tomcat9

Now install tomcat9 admin as well

Sudo apt-get install tomcat9-admin

how can we access the tomcat


Take the publicip of sit server and add 8080(copy paste this
command on the browser)

Now go to below path

Cd /etc/tomcat9
$ll

now we need to add user in the tomcat-users.xml file

Sudo vim tomcat-users.xml

Go to the insert mode


:wq

Now restart the tomcat service

$sudo service tomcat9 restart

Now u can add one plugin in the jenkins (deploy to container)

Manage jenkins-->plugins-->available plugins-->select deploy


to container and install it
Now go to the jenkins dashboard
Select the war job
Select the configure

Select the post build action and searh deploy war/ear to a


container
Add container tomcat 9

Add the credentials

Select the credentials and give the tomcat url (sit server path
along with 8080 port no)
Click on apply and save
And run the build now

How can we check the artifact is deployed or not

Take the sit publicipaddress and port no and give the context
path name

Ex: http://3.110.55.250:8080/sit
AUTOMATION THE JENKINS PIPELINE:

Whenever u made some changes in the source file jenkins job


run automatically fetch the code from github to dev server and
build the war file and deployed into sit

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB
$ git clone https://github.com/Mahi-Repalle/practice.git
Cloning into 'practice'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 59 (delta 9), reused 53 (delta 3), pack-reused 0 (from 0)
Receiving objects: 100% (59/59), 6.13 KiB | 392.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB
$ ll
total 11008
-rw-r--r-- 1 Admin 197121 1555602 Feb 1 20:22 Ansible_Setup.docx
-rw-r--r-- 1 Admin 197121 434977 Feb 20 19:38 'Deploy to Server.docx'
-rw-r--r-- 1 Admin 197121 850944 Jan 8 18:19 EXP1-STEPS.doc
-rw-r--r-- 1 Admin 197121 1886107 Jan 27 19:00 Experiment-2.pdf
-rw-r--r-- 1 Admin 197121 1279778 Jan 21 07:47 Jenkins_setup_on_AWS.docx
-rw-r--r-- 1 Admin 197121 1748522 Feb 15 06:44 War_With_Maven.doc
-rw-r--r-- 1 Admin 197121 314368 Feb 21 18:49 automation.doc
-rw-r--r-- 1 Admin 197121 1725354 Feb 19 20:24 docker.docx
drwxr-xr-x 1 Admin 197121 0 Mar 10 20:35 practice/
-rw-r--r-- 1 Admin 197121 1451061 Jan 26 20:35 'war file.docx'
-rw-r--r-- 1 Admin 197121 162 Feb 19 07:08 '~$docker.docx'
-rw-r--r-- 1 Admin 197121 162 Feb 20 06:31 '~$ploy to Server.docx'
-rw-r--r-- 1 Admin 197121 162 Feb 20 11:38 '~$r_With_Maven.doc'
-rw-r--r-- 1 Admin 197121 162 Feb 19 20:34 '~$sible_Setup.docx'

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB
$ cd practice

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice (master)
$ ll
total 4
-rw-r--r-- 1 Admin 197121 1896 Mar 10 20:35 pom.xml
drwxr-xr-x 1 Admin 197121 0 Mar 10 20:35 src/

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice (master)
$ cd src

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src (master)
$ ll
total 0
drwxr-xr-x 1 Admin 197121 0 Mar 10 20:35 main/

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src (master)
$ cd main

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main (master)
$ ll
total 0
drwxr-xr-x 1 Admin 197121 0 Mar 10 20:35 webapp/

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main (master)
$ cd webapp

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ ll
total 1
drwxr-xr-x 1 Admin 197121 0 Mar 10 20:35 WEB-INF/
-rw-r--r-- 1 Admin 197121 78 Mar 10 20:35 index.jsp

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ vim index.jsp

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:


(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.jsp

no changes added to commit (use "git add" and/or "git commit -a")

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ git add .

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.jsp
Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ git commit -m "ab"
[master 74b2935] ab
1 file changed, 1 insertion(+), 1 deletion(-)

Admin@DESKTOP-ASGG5M3 MINGW64
/d/CMRIT_24_25/24-25_III_2/DEVOPS/DEVOPS_THEORY_LAB_DOCUMENTS/LAB_EXPERIMENT
S/DEVOPS_LAB/practice/src/main/webapp (master)
$ git push origin master
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 469 bytes | 469.00 KiB/s, done.
Total 6 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/Mahi-Repalle/practice.git
b809fbc..74b2935 master -> master

Triggers u can select the poll scm and give the crontab values
*****

Click on apply and save the job

Don’t run the build now

Jenkins automatically trigger the job


Now refresh the sit server latest code changes are reflected in
the sit

You might also like