How to setup Jenkins in Ubuntu EC2 instance?
Setup Jenkins on AWS EC2 Ubuntu instance
1. What is Jenkins?
Jenkins is an open-source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.
Download the Dependencies.
Please follow the steps to install Java, Jenkins, and Maven on the Ubuntu instance. Jenkins, Maven is Java-based applications, so we need to install Java first.
Change Host Name to Jenkins:
sudo hostnamectl set-hostname Jenkins
Perform update first:
sudo apt update
Install Java:
sudo apt install default-jdk -y
Maven Installation:
Maven is a popular build tool used for building Java applications. You can install Maven by executing the below command:
sudo apt install maven -y
You can type mvn --version
you should see the below output:
Now let's start Jenkins installation
Jenkins Setup:
Add Repository key to the system:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Append Debian package repo address to the system:
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
Update Ubuntu package:
sudo apt update -y
Install Jenkins:
sudo apt install jenkins -y
Start Jenkins:
sudo systemctl start jenkins
Check the status of Jenkins:
sudo systemctl status jenkns
Access Jenkins in a web browser:
Now Go to the AWS console. Click on EC2, and click on the running instances link. Connect to your instance using its Public DNS/IP Address.
Now go to the browser. Enter the public DNS name or public IP address with port no 8080.
EC2_public_dns_name:8080
Unlock Jenkins:
Get the initial password from the below file:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the browser. Then click on install suggested plug-ins.
Also, create user name and password. Enter everything as admin. at least the user name as admin password admin.
Click on Save and Finish. Click on start using Jenkins. Now you should see a screen like below:
Conclusion
Jenkins is like the soul of the continuous integration process as it builds and tests the app continuously which makes it easier to integrate changes to the process. Most of the process is automated and this saves time and effort which can be used to perform other tasks related to the delivery. It has some issues like the old UI but the benefits like an active opensource community overshadow the little disadvantages. This is why Jenkins is the most popular CI server among developers.