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.
You need to consider continuous integration (CI) and continuous delivery (CD) to understand Jenkins:
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 used here.
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).
Skip to the next section if you have Java already installed on your system.
To check, please run the following command in the terminal:
$ sudo apt update $ sudo apt install openjdk-8-jdk
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.
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.
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.
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 192.168.1.10 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.
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:
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:
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.
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.
7. Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"
Hit Start using Jenkins button and it will take you to the Jenkins dashboard.
Congratulations! You have completed the installation of 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
2) Create New item:
Click on the New Item on the left-hand side of the dashboard.
3) Fill the project description:
You can enter the job details as per your need.
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,
Now, add the java commands. In this article, we have used javac HelloWorld.java and java HelloWorld.
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.
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.
Follow the instructions to uninstall Jenkins:
$ sudo apt-get remove 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.
Your email address will not be published. Required fields are marked *