Install Jenkins on Ubuntu in 10 Easy Steps
- Last Updated On: August 7, 2020
- By: devopscube
Jenkins 2.x has lots of great functionalities that will make the CI pipeline smooth using the pipeline as code and reusable with shared libraries.
In this guide, we will walk you through the steps for installing and configuring Jenkins on a ubuntu server in 10 easy steps. Also, we have added the steps to install Jenkins using Docker on Ubuntu server.
Install and Configure Jenkins on Ubuntu
Follow the steps given below to install and configure Jenkins 2 on a ubuntu server.
Note: Centos/Rehat users follow this tutorial Install jenkins on centos/Redhat
Step 1: Log in to the server and update it.
sudo apt-get -y update
Step 2: Install open JDK 11.
sudo apt install openjdk-11-jdk -y
Step 3: Add the Jenkins Debian repo.
<code>wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -</code>
<code>sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'</code>
Step 4: Update the packages
sudo apt-get update -y
Step 5: Install latest LTS Jenkins.
sudo apt-get install jenkins -y
Step 6: Start the Jenkins service & enable it for starting during bootup.
sudo systemctl start jenkins sudo systemctl enable jenkins
You can check the status of Jenkins service using the following command.
sudo systemctl status jenkins
Step 7: Now you will be able to access the Jenkins server on port 8080 from localhost or using the IP address as shown below.
Step 8: As you can see in the above image, you need to provide the administrative password. You can get the password using the following command.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and click continue.
Step 9: Next, you will be asked to configure plugins as shown below. Select the “Install Suggested Plugins” option. This will install all the required plugins for building your projects. It will take a few minutes to install the plugins.
Step 10: Once installed, You need to create a user with password and click “save and finish”
Click “Start Using Jenkins” and it will take you to the Jenkins Dashboard. Log in using the username and password that you have given in step 8.
That’s it! Now you have a fully functional Jenkins server up and running. Consider setting up Jenkins backup using the backup plugin.
Here are some key configurations and file locations in Jenkins that you should know.
Note: For production setup, the recommended approach is to mount the Jenkins data folder to an additional data disk. This way you don’t lose any Jenkins data if the server crashes.
Jenkins Data Location | /var/lib/jenkins |
Jenkins main configuration file | /var/lib/jenkins/config.xml |
Jobs folder | /var/lib/jenkins/jobs |
Next, would be the configuration of a distributed master-slave setup wherein you will have an active master and slave agents for building the projects.
Check Jenkins SSL setup guide if you want to setup SSL for your Jenkins instance.
Setting up Jenkins Using Docker on Ubuntu
If you are a docker user, you can run Jenkins on a docker container.
Refer docker installation document to install the latest edition of docker.
Execute the following command to deploy Jenkins on Docker
docker run -p 8080:8080 -p 50000:50000 --name jenkins jenkinsci/jenkins:latest
The above command won’t persist any changes if the container crashes. So it is better to mount a host volume to the container to hold all the Jenkins configurations.
Here is the command to deploy Jenkins container with the host volume mount.
docker run -p 8080:8080 -p 50000:50000 -v /home/ubuntu:/var/jenkins_home jenkinsci/jenkins:latest
devopscube
Other Interesting Blogs
How To Setup Consul Cluster (Multi-Node) on Linux – Beginners Guide
Consul is an open source key-value store. It is used for use cases such as service discovery, config management, etc. This guide
Amazon to equip developers with [email protected]
Two years ago, Amazon Lambda was announced in the Re: Invent conference. And this year, Amazon has the tech world bouncing in
Docker Tutorial : Getting Started With Docker Swarm
Docker swarm is a clustering tool for docker. You can form a swarm cluster using one or more docker hosts. Like Kubernetes
Comments
Nice Article. How it help to developer in terms of balance the day to day life.
This is not directly regarding this article.but I found it difficult to install maven in Jenkins 2.7.2 . Previously I used auto installer. but I haven’t found that option in this version.
Hi Dilshani,
You can find solution at below url:
http://devopsio.com/question/how-to-install-maven-install-automatically-in-jenkins-2-x/
Going forward any questions related CI/CD or DevOps, you can post questions @ http://devopsio.com/
Thank you for your response. Jenkins Moved this option to global tool configuration, I guess they wanted Jenkins to be more organized, which put me in trouble. 😀
Hello! I have problem with step 5. if I understand clearly I have to open file etc/rc.local and then print the line above exit 0 : /etc/init.d/jenkins start. but it says that etc/rc.local is for read only.
@disqus_mYGJ02HuGq:disqus Please use sudo before the command.
Hi,
I tried to set up this way and I’m able to get to the “Getting Started” page, but when I’m giving the password it’s not moving forward. It’s not throwing any error.
Any idea, why this is happening?
Regards
Sammi
Same problem here anybody resolved this yet?
Looks like the problem is with the latest versions 2.7 and 2.8. I installed 2.0 and this problem was not there.
Regards
Sammi
Hi Sammi, we tried with 2.9 and everything is working fine. Also we have updated the article. Thank you for posting the issue!
Run this command to know the password.
$docker exec jenkins-master cat /var/jenkins_home/secrets/initialAdminPassword