This blog will guide you through a detailed but yet easy steps for Jenkins installation on AWS ec2 linux instance. However in order to launch linux instance on AWS, follow this blog.
If you want to see the video for this article, click here
Prerequisite:
Java 8 is a prerequisite. To Install Oracle JDK, Click here to install Java.
Follow this article to install openjdk
sudo yum install wget
yum install java-1.8.0-openjdk
Configure Java HOME
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09–2.amzn2.0.1.x86_64
export PATH
sudo alternatives --config java
Jenkins installation on AWS ec2 linux instance:
Step 1. Firstly, add Jenkins repository using wget, so that yum get to know where to install Jenkins from.
Install wget ,if not installed sudo yum install wget [ec2-user@ip-xxx-xx-xx-xx]$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
*yum is the package manager which can install, remove, update software and can manage all the dependencies for each packages.
Step 2. Now, let’s add the Jenkins GPG key to our trusted keys, so that we will be able to verify/trust the files that are being sourced (while installing Jenkins )are from trusted site.
[ec2-user@ip-xxx-xx-xx-xx]$ sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
As now, the environment has been prepared and has resolved the required dependencies, lets install Jenkins.
[ec2-user@ip-xxx-xx-xx-xx]$ sudo yum install jenkins
Step 3. Jenkins services needs to be started, with the following command:
[ec2-user@ip-xxx-xx-xx-xx]$ sudo service jenkins start
*If you wish to start Jenkins automatically when your linux instance is started, then you can use chkconfig to add Jenkins to your startup services.
[ec2-user@ip-xxx-xx-xx-xx]$ sudo chkconfig --add jenkins
Step 4. Make sure to open port 8080 (default port to which Jenkins listen):
(i) Go to your AWS management console → ec2 dashboard → Network & Security → Choose the security group of your instance
Click on the Inbound tab
Click on edit → Add rule : Custom TCP with Port range 8080
Step 5. Go to your browser and connect to jenkins via default port 8080