flash sale banner

HomeBlogDevOpsHow To Install Jenkins on Ubuntu

How To Install Jenkins on Ubuntu

05th Sep, 2023
view count loader
Read it in
8 Mins
In this article
    How To Install Jenkins on Ubuntu

    Jenkins is a Java-built open-source Continuous Integration (CI) and CD platform. Basically, Jenkins builds software projects, checks and deploys them. This is one of the most practical programming tools you can master, and today we will show you how Jenkins is installed on Ubuntu 18.04. Use this powerful tool to activate your VPS server!

    Jenkins is loved by teams of all sizes, for different language projects like Java, Ruby, Dot Net, PHP etc. Jenkins is a platform that is autonomous, and can be used on Windows, Linux or any other operating system. 


    • Hardware Requirements: 

      • RAM- 4 GB (Recommended) 
      • Storage- more than 50 GB of Hard Disk Space (Recommended)        
    • Software Requirements: 

      • Java: Java Development Kit (JDK) or Java Runtime Environment (JRE).  
      • Web Browser: Any browser such as Google Chrome, Mozilla Firefox, Microsoft Edge. 
      • Operating System: An Ubuntu 18.04 server installed with a non-root sudo user and firewall. For help in the planning of production capability of a Jenkins installation seChoosing the right hardware for Masters. 

    Why Use Jenkins? 

    You need to consider continuous integration (CI) and continuous delivery (CD) to understand Jenkins: 

    • Continuous integration – the practice of continuous production combined with the main industry. 
    •  Continuous delivery – the code is constantly delivered to an area after the code is ready for delivery. It could be for production or staging. The commodity is supplied to a consumer base that can provide QA or inspection by customers. 

    Developers update the code regularly in the shared repository (such as GitHub or TFS). Improvements made in the source code are made at the end of the day, making it difficult to identify the errors. So, Jenkins is usedhere. 

    Once a developer changes the repository, Jenkins will automatically enable the build and immediately warn you in the event of an error (Continuous Integration CI). 

    Installation Procedure: 

    Step 1: Install Java 

    Skip to the next section if you have Java already installed on your system. 

    To check, please run the following command in the terminal: 

    java --version 
    • Jenkins needs Java for running, but it doesn't include certain distributions by default, and Java versions of Jenkins are incompatible. 
    • Multiple Java implementations are available to you. OpenJDK is currently the most popular one, which we will use in this guide. 
    • Being an open-source Java application, Jenkins requires the installation of OpenJDK 8 on your system. The apt repositories can directly access OpenJDK 8. 
    • The installation of OpenJDK from standard repositories is recommended. Open and enter the following in the terminal window: 
    sudo apt update 
    sudo apt install openjdk-8-jdk 
    • The download and installation will be requested. Press the "Y" button and press the Enter button to finish the process. 
    • Java 8 will be installed on your system. We are ready to download Jenkins package now as we have our requirements ready! 

    Step 2: Install Jenkins 

    The default Ubuntu packages for Jenkins are always behind the current version of the project itself. You may use the project-maintained packages to install Jenkins to take advantage of the newest patches and features. 

    1. add the framework repository key: 

    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add  

    The device returns OK when the key is inserted. 

    Install Jenkins

    2. Next, link the repository of Debian packages to the sources.list of the server: 

    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' 

    3. When both are in place, upgrade to apt to use the new repository: 

    sudo apt update 

    4. Install Jenkins: 

    sudo apt install jenkins 

    Now we're going to start the Jenkins server, as Jenkins and its dependencies are in place. 

    Step 3: Start Jenkins 

    1. You can start Jenkins using systemctl: 

    sudo systemctl start jenkins 

    2. As systemctl does not display performance, you can use the status command to check that Jenkins has successfully launched: 

    sudo systemctl status jenkins

    If all went well, the start of the performance should demonstrate that the service is active and ready to boot: 


    jenkins.service - LSB: Start Jenkins at boot time 
       Loaded: loaded (/etc/init.d/jenkins; generated) 
       Active: active (exited) since Sat 2021-04-17 00:34:17 IST; 26s ago 
         Docs: man:systemd-sysv-generator(8) 
      Process: 17609 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCC 

    As Jenkins is running, so adjust the firewall rules to complete our further setup of Jenkins from the web browser. 

    Step 4: Opening the Firewall 

    1. Jenkins works by default on port 8080, so let's open the port with ufw: 

    sudo ufw allow 8080  

    2. Check ufw’s status: 

    sudo ufw status 

    You will see that traffic from anywhere is permitted to port 8080. 


    Status: active 
    To                         Action      From 
    --                         ------      ---- 
    8000                       ALLOW       Anywhere                   
    CUPS                       ALLOW       Anywhere                   
    27017                      ALLOW       Anywhere                   
    27017                      ALLOW               
    8080                       ALLOW       Anywhere                   
    8000 (v6)                  ALLOW       Anywhere (v6)              
    CUPS (v6)                  ALLOW       Anywhere (v6)              
    27017 (v6)                 ALLOW       Anywhere (v6)              
    8080 (v6)                  ALLOW       Anywhere (v6) 

    3. If the firewall is inactive, the following commands will allow OpenSSH and turn it back on: 

    sudo ufw allow OpenSSH 
    sudo ufw enable 

    We can finish the initial configuration with Jenkins installed and our firewall configured. 

    Note: If you decide to continue to use Jenkins, use a Nginx Reverse Proxy at Ubuntu 18.04 to configure Jenkins with SSL when your exploration has been completed to protect your passwords and any sensitive system or product information sent between the machine and the server in plain text. 

    Step 5: Setting Up Jenkins 

    1. To set up installation, visit Jenkins on its default 8080 port with your server domain name or IP address: http://your_server_ip_or_domain:8080 

    You should see the Unlock Jenkins screen, which displays the initial password's location:

    Unlock Jenkin

    2. You can use the cat command to display the password: 

    sudo cat /var/lib/jenkins/secrets/initialAdminPassword 

    3. Copy the alphanumeric terminal 32-character password and paste into the Administrator Password field, then click Continue. 



    The following screen shows the ability to install or select certain plugins: 

    Customize jenkins

    4. We will click on the option to install proposed plugins to start the installation process immediately. 

    5. When the installation is done, the first administrative user will be prompted. You can save this step and use your initial password to continue as an Admin. However, we will take some time to create the user. 

    The Jenkins default server is NOT encrypted to prevent data from being protected. Use the Nginx Reverse Proxy on Ubuntu 18.04 to configure Jenkins with SSL. This protects the information of users and builds transmitted through the web interface. 

    Create First Admin User

    6. You will see a configuration instance page, which asks you to confirm your Jenkins instance's URL of choice. Confirm either your server's domain name or the IP address of your server.  

    Instance Configuration

    7. Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"  

    Jenkins is ready

    Hit Start using Jenkins button and it will take you to the Jenkins dashboard.  

    Welcome to Jenkin

    Congratulations! You have completed the installation of Jenkins. 

    Step 6: Creation of New Build Jobs in Jenkins: 

    The freestyle job is a highly versatile and user-friendly choice. It's easy to set up and many of its options appear in many other build jobs. For all projects, you can use it. 

    Follow the following steps: 

    You have to login to your Jenkins Dashboard by visiting

    Welcome to jenkin

    2) Create New item: 

    Click on the New Item on the left-hand side of the dashboard.

     Create New item

    3) Fill the project description: 

    You can enter the job details as per your need.

     Fill the project description

    4) Source Code Management: 

    Under source code management, enter the repository URL.
    You can also use a Local repository. 

    5) Build Environment: 

    Now in the Build section, 

    • Click on the “Add build Setup” 
    • Select "Execute Windows batch command".

     Build Environment

    Now, add the java commands. In this article, we have used javac HelloWorld.java and java HelloWorld.   

     Build Environment

    6) Save the project: 

    Click Apply and save the project. 

    7) Build Source Code and check its status: 

    Click on “Build Now” on the left-hand side of the screen to create the source code. 

    8) Console Output: 

    Select the build number and click on “Console Output” to check the status of the build run. 

    Console Output

    When it shows success, it means that we have successfully run the HelloWorld program from the cGitHub Repository. 

    In case of failure, you can check the job logs by clicking on failure icon and debug the root cause.

    Uninstall Jenkins 

    Follow the instructions to uninstall Jenkins: 

    sudo apt-get remove jenkins 

    Uninstall Jenkins

    Uninstall Jenkins: 

    sudo apt-get remove --auto-remove jenkins 

    Purging your data: 

    sudo apt-get purge jenkins 

    or you can use: 

    sudo apt-get purge --auto-remove jenkins 


    Installing Jenkins on Ubuntu is really that easy. Jenkins has a low learning curve and so you can start to work with it as quickly as possible. 

    In the above article we have learned how to install Jenkins in an Ubuntu machine where all the steps are explained clearly. In case you want to learn more about the core concepts of Jenkins Jobs, Pipelines, Distributed System, Plugins, and how to use Jenkins in depth you can enroll for our course Jenkins Certification Course. 


    Abhresh Sugandhi


    Abhresh is specialized as a corporate trainer, He has a decade of experience in technical training blended with virtual webinars and instructor-led session created courses, tutorials, and articles for organizations. He is also the founder of Nikasio.com, which offers multiple services in technical training, project consulting, content development, etc.

    Share This Article
    Ready to Master the Skills that Drive Your Career?

    Avail your free 1:1 mentorship session.

    Your Message (Optional)

    Upcoming DevOps Batches & Dates

    NameDateFeeKnow more
    Course advisor icon
    Course Advisor
    Whatsapp/Chat icon