{"id":745,"date":"2022-12-28T01:43:00","date_gmt":"2022-12-28T01:43:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=745"},"modified":"2022-12-28T01:43:00","modified_gmt":"2022-12-28T01:43:00","slug":"install-configure-jenkins-2-0","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=745","title":{"rendered":"How to Install Jenkins on Ubuntu in 10 Easy Steps [Updated]"},"content":{"rendered":"<p>In this guide, we will walk you through the steps to install Jenkins on the latest Ubuntu server and use all recommended configurations in 10 easy steps.<\/p>\n<p><a href=\"https:\/\/devopscube.com\/jenkins-2-tutorials-getting-started-guide\/\" rel=\"noreferrer noopener\">Jenkins 2.x<\/a> has lots of great functionalities that will make the CI pipeline smooth using the <a href=\"https:\/\/devopscube.com\/jenkins-pipeline-as-code\/\" rel=\"noreferrer noopener\">pipeline as code<\/a> and reusable with <a href=\"https:\/\/devopscube.com\/jenkins-shared-library-tutorial\/\" rel=\"noreferrer noopener\">shared libraries<\/a>.<\/p>\n<p>Also, we have added the steps to install <strong>Jenkins using Docker on the Ubuntu<\/strong> server.<\/p>\n<h2 id=\"install-jenkins-on-ubuntu-with-recommended-configurations\">Install Jenkins on Ubuntu With Recommended Configurations<\/h2>\n<p>Follow the steps given below to install and configure Jenkins 2 on a ubuntu server.<\/p>\n<blockquote><p><strong>Note:<\/strong> Centos\/Rehat users follow this tutorial <a href=\"https:\/\/devopscube.com\/install-configure-jenkins-2-centos-redhat-servers\/\" rel=\"noopener noreferrer\">Install jenkins on centos\/Redhat<\/a><\/p><\/blockquote>\n<p><strong>Step 1:<\/strong> Log in to the server and update the package list.<\/p>\n<pre><code>sudo apt -y update<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Jenkins needs the Java runtime as it is based on Java. Install open JDK 11 package using the following command.<\/p>\n<pre><code>sudo apt install default-jdk -y<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Add the Jenkins Debian repo.<\/p>\n<pre><code>sudo wget -O \/usr\/share\/keyrings\/jenkins-keyring.asc \\\n  https:\/\/pkg.jenkins.io\/debian-stable\/jenkins.io-2023.key<\/code><\/pre>\n<pre><code>echo deb [signed-by=\/usr\/share\/keyrings\/jenkins-keyring.asc] \\\n  https:\/\/pkg.jenkins.io\/debian-stable binary\/ | sudo tee \\\n  \/etc\/apt\/sources.list.d\/jenkins.list &gt; \/dev\/null<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Update the package list again.<\/p>\n<pre><code>sudo apt update -y<\/code><\/pre>\n<p><strong>Step 5:<\/strong> Install the latest LTS Jenkins.<\/p>\n<blockquote><p><strong>Note:<\/strong> You can check the <a href=\"https:\/\/pkg.jenkins.io\/debian-stable\/?ref=devopscube.com\" rel=\"noreferrer noopener\">official Jenkins ubuntu package repo<\/a> for more information on the latest versions<\/p><\/blockquote>\n<pre><code>sudo apt-get install jenkins -y<\/code><\/pre>\n<p><strong>Step 6:<\/strong> Start the Jenkins service &amp; enable it for starting during bootup.<\/p>\n<pre><code>sudo systemctl start jenkins sudo systemctl enable jenkins<\/code><\/pre>\n<p>You can check the status of the Jenkins service using the following command.<\/p>\n<pre><code>sudo systemctl status jenkins<\/code><\/pre>\n<p><strong>Step 7: <\/strong>Now you will be able to access the <strong>Jenkins server on port 8080<\/strong> using the IP address as shown below.<\/p>\n<blockquote><p>Note: You can also run Jenkins on port 80. Check this <a href=\"https:\/\/devopscube.com\/access-run-jenkins-port-80\/\" rel=\"noreferrer noopener\">Jenkins guide to change access port<\/a><\/p><\/blockquote>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/1-4.png\" class=\"kg-image\" alt=\"jenkins unlock admin password on Ubuntu\" loading=\"lazy\" width=\"991\" height=\"412\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/1-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/1-4.png 991w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>Step 8:<\/strong> As you can see in the above image, you need to provide the administrative password. You can get the password using the following command.<\/p>\n<pre><code>sudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/code><\/pre>\n<p>Copy the password and click continue.<\/p>\n<p><strong>Step 9:<\/strong> Next, you will be asked to configure plugins as shown below. Select the &#8220;Install Suggested Plugins&#8221; option. This will install all the required plugins for building your projects. It will take a few minutes to install the plugins.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2-10.png\" class=\"kg-image\" alt=\"install suggested Jenkins plugins on ubuntu\" loading=\"lazy\" width=\"800\" height=\"389\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2-10.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2-10.png 800w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>Step 10:<\/strong> Once installed, You need to create a user with a password and click &#8220;save and finish&#8221;<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/3-7.png\" class=\"kg-image\" alt=\"Jenkins 2.0 user configuration\" loading=\"lazy\" width=\"676\" height=\"305\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/3-7.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/3-7.png 676w\"><\/figure>\n<p>Click &#8220;<strong>Start Using Jenkins<\/strong>&#8221; and it will take you to the Jenkins Dashboard. Log in using the username and password that you have given in step 8.<\/p>\n<p>That&#8217;s it! Now you have a fully functional Jenkins server up and running. Consider <a href=\"https:\/\/devopscube.com\/jenkins-backup-data-configurations\/\" rel=\"noreferrer noopener\">setting up Jenkins backup<\/a> using the backup plugin.<\/p>\n<h2 id=\"install-jenkins-on-ubuntu-using-war-file\">Install Jenkins on Ubuntu Using war file<\/h2>\n<p>There are situations where you cannot access the ubuntu public repo. In this case, you can opt for Jenkins installation using the java war file.<\/p>\n<p>Head over to the <a href=\"https:\/\/www.jenkins.io\/download\/?ref=devopscube.com\" rel=\"noreferrer noopener\">Jenkins downloads page<\/a>. There you will find a link to download the war file as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-26-27.png\" class=\"kg-image\" alt=\"Jenkins war file download for Ubuntu\" loading=\"lazy\" width=\"564\" height=\"356\"><\/figure>\n<h2 id=\"jenkins-agent-setup-on-ubuntu\">Jenkins Agent Setup on Ubuntu<\/h2>\n<p>Next, you need to configure a distributed master-slave setup wherein you will have active master and slave agents for building the projects.<\/p>\n<p>Follow the <a href=\"https:\/\/devopscube.com\/setup-slaves-on-jenkins-2\/\" rel=\"noreferrer noopener\">Jenkins master-agent setup<\/a> guide to configure a Jenkins agent<\/p>\n<p>If you are looking for a cloud Docker agent, follow the <a href=\"https:\/\/devopscube.com\/docker-containers-as-build-slaves-jenkins\/\" rel=\"noreferrer noopener\">Docker-based Jenkins build agents<\/a> guide.<\/p>\n<h2 id=\"ssl-for-jenkins-url\">SSL for Jenkins URL<\/h2>\n<p>If you are setting up a Jenkins server for a project, consider setting up SSL for the Jenkins server URL.<\/p>\n<p>Follow the<a href=\"https:\/\/devopscube.com\/configure-ssl-jenkins\/\" rel=\"noreferrer noopener\"> Jenkins SSL setup guide<\/a> to configure SSL.<\/p>\n<h2 id=\"jenkins-key-configurations-on-ubuntu\">Jenkins Key Configurations on Ubuntu<\/h2>\n<p>Here are some key configurations and file locations in Jenkins that you should know.<\/p>\n<blockquote><p><strong>Note:<\/strong> The recommended approach is to mount the Jenkins data folder to an additional data disk for production setup. This way, you don&#8217;t lose any Jenkins data if the server crashes.<\/p><\/blockquote>\n<p><!--kg-card-begin: html--><\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Jenkins Data Location<\/strong><\/td>\n<td>\/var\/lib\/jenkins<\/td>\n<\/tr>\n<tr>\n<td><strong>Jenkins main configuration file<\/strong><\/td>\n<td>\/var\/lib\/jenkins\/config.xml<\/td>\n<\/tr>\n<tr>\n<td><strong>Jenkins<\/strong> <strong>Jobs folder<\/strong><\/td>\n<td>\/var\/lib\/jenkins\/jobs<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--kg-card-end: html--><\/p>\n<h2 id=\"setting-up-jenkins-using-docker-on-ubuntu\">Setting up Jenkins Using Docker on Ubuntu<\/h2>\n<p>If you are a docker user, you can run Jenkins on a docker container.<\/p>\n<p>Refer <a href=\"https:\/\/devopscube.com\/how-to-install-and-configure-docker\/\" rel=\"noreferrer noopener\">docker installation document<\/a> to install the latest edition of docker.<\/p>\n<p>Execute the following command to deploy Jenkins on <a href=\"https:\/\/devopscube.com\/what-is-docker\/\" rel=\"noreferrer noopener\">Docker<\/a><\/p>\n<pre><code>docker run -p 8080:8080 -p 50000:50000 --name jenkins jenkinsci\/jenkins:latest<\/code><\/pre>\n<p>The above command won&#8217;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.<\/p>\n<p>Here is the command to deploy the Jenkins container with the host volume mount.<\/p>\n<pre><code>docker run -p 8080:8080 -p 50000:50000 -v \/home\/ubuntu:\/var\/jenkins_home jenkinsci\/jenkins:latest<\/code><\/pre>\n<h2 id=\"setting-up-ubuntu-based-jenkins-on-kubernetes\">Setting up Ubuntu Based Jenkins on Kubernetes<\/h2>\n<p>You can run Jenkins on Kubernetes using the ubuntu based docker image for Jenkins.<\/p>\n<p>Follow our <a href=\"https:\/\/devopscube.com\/setup-jenkins-on-kubernetes-cluster\/\" rel=\"noreferrer noopener\">Jenkins deployment on kubernetes<\/a> guide.<\/p>\n<p>Consider using a kubernetes persistent volume to mount the data directly to avoid data loss if the Jenkins pod restarts.<\/p>\n<h2 id=\"jenkins-installation-faqs\">Jenkins Installation FAQ&#8217;s<\/h2>\n<h3 id=\"can-we-install-jenkins-in-ubuntu\">Can we install Jenkins in Ubuntu?<\/h3>\n<p>Yes. We can install Jenkins on Ubuntu. You can choose to install a specific version or the latest available version from the apt repository.<\/p>\n<h3 id=\"how-do-i-know-if-jenkins-is-installed-in-ubuntu\">How do I know if Jenkins is installed in Ubuntu?<\/h3>\n<p>You can check if Jenkins is installed in Ubuntu by executing the command <code>apt-cache policy jenkins <\/code><\/p>\n<p>Also, you can list the installed Jenkins package using <code>dpkg -l | grep jenkins<\/code>Ubuntu<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>In this guide, you have learned to install Jenkins on an Ubuntu server using different methods.<\/p>\n<p>After the installation, make sure you back up the Jenkins data folder before making any major changes to the configurations. For some reason, if you break Jenkins, you can easily restore it from the backup files.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/install-configure-jenkins-2-0\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Install Jenkins on Ubuntu in 10 Easy Steps [Updated] \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/install-configure-jenkins-2-0\/<\/p>\n","protected":false},"author":1,"featured_media":746,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-745","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=745"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/745\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/746"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}