How To Install Jenkins Server On AWS EC2 Instance

Introduction 

 
Jenkins is an open-source Continuous Integration server which helps you to perform a chain of actions and thus helps you to achieve the Continuous Integration.
 
In Continuous Integration after a code commit, the software is built and tested immediately. So, in large projects where there are a lot of developers, they commit code many times in a day. So, with Jenkins after every commit, code is built and tested and if all goes well then continuous deployment happens.
 
Jenkins is not the only tool in this field, there are a lot of Continuous Integration tools available in the market like Bamboo, TeamCity, CircleCI, Travis, etc. but Jenkins is one of the most popular CI Tool.
 
As this article is not about CI, we will not go into the details of CI but we can simply understand the process of continuous integration (CI) with the help of the pictorial representation below.
 
How to Install Jenkins Server On AWS EC2 Instance
 
So, in this article, we will learn how we can set up Jenkins on AWS EC2 instance.
 
In my previous article Host your sample app in AWS instance using EC2 service we saw how we can host an application on EC2 instances and also learned about setting up security group, key pair, inbound rules, etc. Thus, in this article, we will be focusing on the actual installation and set up of Jenkins.
 
So, let’s get started now.
 
Step 1
 
Just log in to the AWS management console and from EC2 dashboard, create a new instance using the Ubuntu server (Free tier eligible).
 
How to Install Jenkins Server On AWS EC2 Instance
 
Select this AMI and follow the steps like adding tags, configuring security groups, etc. hit Launch.
 
How to Install Jenkins Server On AWS EC2 Instance
 
So, we can see above that our Jenkins server instance is running successfully.
 
Step 2
 
In this step, we will SSH to our Jenkins server using Git bash.
 
How to Install Jenkins Server On AWS EC2 Instance
 
Step 3
 
After successful login, we are going to run some commands step by step, which are required to install Jenkins on a Linux machine. We can see those commands mentioned here.
 
These are the commands which we executed.
 
How to Install Jenkins Server On AWS EC2 Instance
 
After this, install JDK as this is one of the dependencies for Jenkins.
 
How to Install Jenkins Server On AWS EC2 Instance
 
Then finally run,
 
sudo apt-get install jenkins
 
Step 4
 
Now after the completion of Step 3 we can check the status of whether Jenkins has been installed successfully or not. For that, we will use the systemctl command.
 
How to Install Jenkins Server On AWS EC2 Instance
 
Here, we can clearly see that the status is active which means that Jenkins is installed and is up and running successfully.
 
Step 5
 
We know that Jenkins is a web-based service which runs on port 8080. So, we have to add one inbound rule for port 8080 so that Jenkins server will allow the request from my IP.
 
How to Install Jenkins Server On AWS EC2 Instance
 
Step 6
 
Next is just take the public IP of the Jenkins server instance which we created in AWS and hit it in the browser.
 
How to Install Jenkins Server On AWS EC2 Instance
 
See, it's up and asking for the administrator password so that we can log in for the first time and create a user.
 
So, as mentioned above, we can get the initial admin password using the below command.
 
How to Install Jenkins Server On AWS EC2 Instance
 
We can see that we got our admin initial password. Every time you install Jenkins, you will get a different password.
 
Step 7
 
After entering the password, it will take us to the screen where we can choose options of installing plugins and after installation is completed, Jenkins will ask us to create our first admin user so that we can Manage Jenkins and create and configure Jobs.
 
How to Install Jenkins Server On AWS EC2 Instance
 
So, after Save and Continue, Jenkins is ready, and its setup is complete.
 
How to Install Jenkins Server On AWS EC2 Instance
 
Now we can simply hit the URL http://13.57.27.233:8080/ and can log in with the admin user account and can set up jobs and manage Jenkins.
 

Summary

 
In this article, we saw a little Introduction about CI and Jenkins (Jenkins is a self-contained, open-source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software) and also saw how we can install it on AWS EC2 instance and what are the different steps involved right from installing to setting up Jenkins.
 
I hope you find this article helpful. Stay tuned for more … Cheers!!


Similar Articles