AWS Jenkins Installation & Configuration (Part III)
So you can build your DevOps Pipelines!
Jenkins Installation, Setup, and Configuration.
This is Part 3 of a complete Jenkins installation, Setup, and Configuration on AWS. The Jenkins installation, Setup, and Configuration on an AWS EC2 instance requires multiple parts:
Part II: Connect (SSH) to your Jenkins Server
Part II: Install Jenkins and Configure it (this article)
Bonus: Stopping and Restarting your AWS EC2 Instance (coming soon)
In this article, we will implement:
Part 3: Install Jenkins and Configure it
Part 3: Install Jenkins and Configure it
This section itself requires a three-part process as well. In the first section, we will install Java and the Jenkins executable on the EC2 Instance. In the second section, we will configure the global settings. And finally, in the third section, we will configure the GIT Server configuration, which is required in order to run the Jenkins pipelines with GIT successfully.
JENKINS INSTALL ON AWS EC2 LINUX Instance
Step 1: Install Java Open JDK
sudo amazon-linux-extras install -y java-openjdk11
Step 2: Verify Java 11 is installed
java — version
You should see something similar to this:
openjdk version “11.0.16” 2022–07–19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.16+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing)
Step 3: Add the Jenkins Repo
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
Step 4: Add the Jenkins keys to download the Jenkins build
sudo rpm — import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Step 5: Install the Jenkins Build in the AWS Instance (requires EPEL — Extra Packages for Enterprise Linux)
sudo amazon-linux-extras install epel
[Enter Y]
sudo yum install -y jenkins
Step 6: Enable the Jenkins service to start
sudo chkconfig jenkins on
Step 7: Start Jenkins
sudo service jenkins start
You should see something similar to this:
Starting jenkins (via systemctl): [ OK ]
Step 8: Open your local browser and enter the PUBLIC IP of your EC2 Instance
WARNING: Do not use Chrome because google will block the URL since we are using HTTP and not HTTPS.
http://[YOUR-EC2-LINUX2-INSTANCE-IP]:8080/
e.g: http://3.101.155.183:8080/
Step 9: To get the initial password, open or cat your initial admin password file:
SSH into your Jenkins server and get the Admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password to the password field.
Step 10: Select “Install suggested plugins”
Step 11: Create A New Admin Password
Step 12: Click “Save and Finish”
(Do not change to localhost)
JENKINS INSTALL — Global Tool Configuration
At this point, we have our Jenkins up and running, but we haven’t configured Java and Maven so that Jenkins knows where to find them. We are doing that in this section.
Assumptions: You are logged in to your Jenkins EC2 Instance Admin Console
Want to become a DevOps Engineer? Get Started using my Step by Step DevOps Project Course using DevOps Tools. The price is unusual!
Step 1: Configure Java 11
In this section, you will configure the Jenkins Server to utilize the Java version you installed on the Jenkins EC2 Instance server.
Note: (this is the path to the Java bin we installed in the prior lab): /usr/lib/jvm/java-11-openjdk-11.0.16.0.8–1.amzn2.0.1.x86_64/bin/
Note: The Java JDK name should be exactly “JDK”; otherwise, the Jenkinsfile will not identify the variable as the Java tool name.
Note: This is the java path: /usr/lib/jvm/java-11-openjdk-11.0.16.0.8–1.amzn2.0.1.x86_64/bin/
Step 2: Configure Maven
Note: The Maven name should be exactly “M3” with the capital “M”; otherwise, the Jenkinsfile will not identify the variable as the Maven tool name.
Step 3: Click “Apply” and verify all configurations were “Saved”
JENKINS ADDITIONAL CONFIGURATION
Depending on the latest version of Jenkins, Jenkins might require additional configuration in order to connect to GitHub. This lab will cover the installation or configurations required on the latest Jenkins version.
ADDITIONAL CONFIGURATION: INSTALL GIT IN YOUR JENKINS EC2 INSTANCE
Step 1: Install Git in your Jenkins EC2 instance
sudo yum install git -y
ADDITIONAL CONFIGURATION: ADD THE GITHUB.COM HOST TO THE KNOWN_HOSTS FILE.
This step is necessary to allow the connections between Jenkins and the GitHub server.
Step 1: On your Jenkins EC2 instance, type the following command and enter “yes” when prompted
- ssh -vvv git@github.com
Step 2: Add github.com host to the knows_host file
FIRST: SSH to your EC2 Jenkins
sudo su -s /bin/bash jenkins
whoami
echo $USER
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
That’s it! This completes Part 3: AWS Jenkins Installation & Configuration. Your Jenkins Server is ready to run your DevOps Pipelines!
Get Started using my Step by Step DevOps Project Course using DevOps Tools. Currently on Sale on Udemy.
Was this lab helpful? If this lab was helpful and you successfully installed Jenkins on your AWS EC2 Instance, I kindly ask that you share this post or give me some applauses so that others can also find the post.