0% found this document useful (0 votes)
14 views

Installation of Jenkins

1. The document describes steps to setup Jenkins on an EC2 instance including installing Java, Jenkins, configuring the AWS cloud plugin, and running a first Jenkins job. 2. It then covers installing Git on the Jenkins server and running a Git Jenkins job. 3. The steps continue with downloading and configuring Maven, updating environment variables, and building to connect to a Gitlab repository. 4. Next it outlines downloading, extracting, and configuring Tomcat including adding user roles and deploying a WAR file from Jenkins. 5. The document concludes with setting up continuous integration and deployment where code changes trigger automated Jenkins jobs that deploy to Tomcat.

Uploaded by

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

Installation of Jenkins

1. The document describes steps to setup Jenkins on an EC2 instance including installing Java, Jenkins, configuring the AWS cloud plugin, and running a first Jenkins job. 2. It then covers installing Git on the Jenkins server and running a Git Jenkins job. 3. The steps continue with downloading and configuring Maven, updating environment variables, and building to connect to a Gitlab repository. 4. Next it outlines downloading, extracting, and configuring Tomcat including adding user roles and deploying a WAR file from Jenkins. 5. The document concludes with setting up continuous integration and deployment where code changes trigger automated Jenkins jobs that deploy to Tomcat.

Uploaded by

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

1.

Setup EC2 instance - Install Java, Install Jenkins, Start Jenkins, Access Web UI
on port = 8080

a. Ensure that your software packages are up to date on your instance ==> sudo yum
update –y
Add the Jenkins repo ==> sudo wget -O /etc/yum.repos.d/jenkins.repo
https://pkg.jenkins.io/redhat-stable/jenkins.repo
Import a key file from Jenkins-CI to enable installation from the package ==>
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key; sudo yum
upgrade

b. Install Java ==> sudo amazon-linux-extras install java-openjdk11 -y

c. Install Jenkins ==> sudo yum install jenkins -y


Enable the Jenkins service to start at boot ==> sudo systemctl enable jenkins
Start Jenkins as a service ==> sudo systemctl start jenkins
Check the status of the Jenkins ==> sudo systemctl status jenkins

d. Connect to http://<your_server_public_DNS>:8080 from your browser


/var/lib/jenkins/secrets/initialAdminPassword

e. Configure Jenkins
Install Amazon EC2 plugin
Configure a cloud
Add a new cloud = Amazon EC2
AWS EC2 Credentials -> Add:
select Kind = AWS Credentials and add IAM User
programmatic access keys with permissions to launch EC2 instances = Access Key and
Secret Key
Region -> Select
EC2 Key Pair’s Private Key -> Add:
select Kind = SSH Username with private key and add
the Private-Key
Test Connection = Success

f. Run First Jenkins Job


Script = echo "Hello! Welcome to Jenkins World!"
Build Now - Job should run successfully and see the above output in the
console

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

2. Install Git with Jenkins

a. Install git on jenkins server => sudo yum install git -y; git version

b. Run Git Jenkins Job


Source Code Management - select Git, add Repository URL (if unable to
add, then add the git path to the Global Configurations)
Build Now - Job should run successfully and see the above output in the
console

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

3.

sudo cd /var/lib/maven
sudo wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-
bin.tar.gz

sudo tar -xvzf apache-maven-3.9.0-bin.tar.gz

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

sudo vim ~/.bash_profile

sudo update-alternatives --config java


/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64/bin/java

/opt/apache-maven-3.9.0

source ~/.bash_profile

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

Build and check if you are able to connect to Gitlab and get the code

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

4.

sudo amazon-linux-extras install java-openjdk11 -y

sudo su -

cd /opt

wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.72/bin/apache-tomcat-
9.0.72.tar.gz

tar -zvxf apache-tomcat-9.0.72.tar.gz

cd apache-tomcat-9.0.72/bin/

chmod +x startup.sh
chmod +x shutdown.sh

ln -s /opt/apache-tomcat-9.0.72/bin/startup.sh /usr/local/bin/tomcatup
ln -s /opt/apache-tomcat-9.0.72/bin/shutdown.sh /usr/local/bin/tomcatdown

tomcatup

cd ..

find -name context.xml

./conf/context.xml
./webapps/examples/META-INF/context.xml
./webapps/host-manager/META-INF/context.xml
./webapps/manager/META-INF/context.xml

#comment value tag sections in below all files

vi ./webapps/examples/META-INF/context.xml
vi ./webapps/host-manager/META-INF/context.xml
vi ./webapps/manager/META-INF/context.xml

cd apache-tomcat-9.0.55
cd conf

vi tomcat-users.xml

#Add below lines between <tomcat-users> tag

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-
jmx,manager-status"/>
<user username="deployer" password="deployer" roles="manager-script"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

Download plugin - Deployer

Create creds
Add tomcat deatils and build
cd webapps - here war file gets deployed

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

CICD:

Change code in GIT UI : Build the job(PULL SCM - */2 * * * *)


Change the code in GIT-BASH and Push it to Git -> Jenkins automatically deploys to
Tomcat after 2mins

You might also like