How To Install Jenkins on Ubuntu 16.04
Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks such as building, testing, and deploying software.
Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with the Java Runtime Environment installed.
In this tutorial, we will install Jenkins by adding its Debian package repository, then using that repository to install the package using “apt-get”.
1. We need to add Jenkins to the repository on the system, by using the below code.
wget -q -O – https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add –
2. When the key is added successfully, you need to append the “Debian Package Repository” to the server’s “Sources.List”, you can do this through the below command.
sudo sh -c ‘echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
3. Let’s update our packages, through the below command.
sudo apt-get update
4. Now we are fully ready to install Jenkins including Java, run the below command on “Terminal”.
sudo apt-get install jenkins
type “Y” and press Enter to continue.
5. After the installation is done, run the below command to start Jenkins.
sudo systemctl start jenkins
6. To make sure that “Jenkins” is working normally, run below command to check status.
sudo systemctl status jenkins
If everything is well and like it shown on the above image, then we will move to next phase of our tutorial and open the firewall for Jenkins.
Open “Firewall” for Jenkins
It’s known that “Jenkins” runs on port “8080”, so we need to open this port and we can do this through the coming steps.
1. All port “8080” on firewall through the below command.
sudo ufw allow 8080
2. To check the status of your firewall and make sure that port “8080” is working from anywhere, do that through the below command.
sudo ufw status
3. Now our ports is working, let’s complete the set-up of Jenkins, open your web browser and go to your IP or domain name following by “:8080”.
4. To unlock “Jenkins”, you will need the administrator password, using the below code on “Terminal” to figure it.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
5. Copy the 32 character that will show just like the above screenshot and paste it to move to next step.
6. Click on “Install Suggested Plugins”, and it will start to install the required plugins.
7. Once all plugins are installed, it will prompt to create the first Admin user, you can skip this by clicking “Continue as admIn”, but i recommend to do it so you don’t have to copy the long password above every time.
8. Once you create the “Admin” user, you will be able to see “Jenkins is ready”, you are almost done, click “Start using Jenkins”.
Now, Jenkins has been successfully installed.