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.
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).
Select this AMI and follow the steps like adding tags, configuring security groups, etc. hit Launch.
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.
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.
After this, install JDK as this is one of the dependencies for Jenkins.
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.
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.
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.
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.
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.
So, after Save and Continue, Jenkins is ready, and its setup is complete.
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!!