You are on page 1of 4

Jenkins install in EC2:

You can use Putty or MobaXterm to login to EC2. Need to use the key downloaded from EC2
security group to login.

https://www.jenkins.io/download/

Use the Red Hat version of download for Linux based EC2.

https://pkg.jenkins.io/redhat-stable/

Login as root user in EC2 with sudo su –

Execute the commands given in https://pkg.jenkins.io/redhat-stable/


sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-
stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

execute “sudo amazon-linux-extras install epel” in EC2.

Note: If you missed to install the above epel package, you may not be able to install Jenkins.

you can install java-11 openjdk and Jenkins with the following command

amazon-linux-extras install java-openjdk11

yum install jenkins

(or) you can use the below to install java-11 openjdk and jenkins
yum install fontconfig java-11-openjdk
yum install jenkins

You can start the Jenkins server using “service Jenkins start”

You can check the status of Jenkins using “service Jenkins status”

Use the public IP of the EC2 instance . While creating EC2 instance, you should have enabled port
8080 in the security group. If not then update the security group for 8080 so that you can connect
with Jenkins from browser using the EC2 instance IP address.
The default password for Jenkins admin user login will be available in the path in EC2:

/var/lib/Jenkins/secrets/initialAdminPassword

Git should have been installed in the EC2 instance along with Jenkins so that it can pull code from the
GitHub. The above figure shows where the developer has git installed in his local machine so that he
can push the completed code to GitHub then the git in EC2 server along with Jenkins will pull the
code from GitHub.

Note: If you want to change the hostname of your EC2 instance for your viewing convenience then
you can update the /etc/hostname.

To install Git in the EC2 instance where Jenkins was installed, use the below command.

yum install git

note: yum is used for install in Linux.

git –version will display the installed version of git.

To install github plugin in Jenkins GUI, goto Manage Jenkins option in the Jenkins GUI. Select Manage
Plugins. Goto Available tab. Search for github. Select GitHub and click install without restart.

Integrating Jenkins with GitHub:

After install of github in Jenkins GUI, select Manage Jenkings option in the Jenkins GUI. Select Global
Tool Configuration in GUI to configure the path for git installed in the EC2 server with GitHub. The
command ‘whereis git’ in EC2 will give the path of git in EC2. But we can optionally just state ‘git’ in
GUI for the field ‘Path to Git executable’ and no need to specifically give the complete path.

Pull code from GitHub to Jenkins:


To pull code from GitHub to Jenkins, configure a new item in Jenkins. Select Freestyle project. Specify
the Github folder URL that you want to copy to Jenkins in the GUI’s Repository URL field. Save. Build
and run. You can check he pulled code in EC2 path: /var/lib/Jenkins/workspace/

Integrate Maven with Jenkins:

The steps for Maven installation in Linux are available in: maven.apache.org/install.html.

Copy the URL for Maven download from the website and download to EC2 using wget followed by
the URL path. Extract the tar.gz file. Set the path for mvn executable in .bash_profile. Edit
the .bash_profile file and set the M2_HOME=/opt/maven and M2=/opt/maven/bin then set
JAVA_HOME=/usr/lib/jvm/….(the jdk filename here). Update the PATH variable in the
same .bash_profile with $M2_HOME:$M2:$JAVA_HOME

Install Maven plugin in the Jenkins GUI by searching for Maven integration plugin through Manage
Jenkins. In configuration, provide configuration for JDK path of EC2. Provide the build path aswell.

Install Tomcat in EC2:

Steps to be provided here….

After installing and configuring Tomcat. You can start the Tomcat server using:
/opt/tomcat/bin/startup.sh.

Tomcat-users.xml to have the user details.

Integrate Jenkins with Tomcat:

1. Install ‘Deploy to container’ plugin in Jenkins GUI


2. Configure Tomcat server with credentials (use the deployer user that has manager-script
role.)

You might also like