How to Install Jenkins on Ubuntu


Jenkins is a software package for software developers. It’s used to automate parts of the testing, build, delivery, and deployment of software. This guide will help you install Jenkins on an Ubuntu 18.04 system.

Prerequisites

  • A system running Ubuntu 18.04 Bionic Beaver
  • A user account with sudo privileges
  • Access to a terminal window / command line (CTRL+ALT+T or search > terminal)
  • Java 8 or 11
A Brief Note on Jenkins Jenkins is a CI/CD software platform that supports continuous integration (CI) and continuous delivery (CD). CI pushes code changes regularly into the official repository. CD implements changes regularly through build, testing, and deployment. Jenkins requires the Java Runtime Environment (JRE). This guide uses OpenJDK for the Java environment. OpenJDK is a Development Kit, and includes the Java Runtime Environment. At this time, Jenkins only supports Java 8 and Java 11 on Ubuntu. You can have multiple different versions of Java installed on your system. If you do, make sure Java 8 or Java 11 is set to the default.

Step 1: Install Java

If you already have Java installed on your system, skip ahead to the next section. It is recommended that you install OpenJDK from the default repositories. Open a terminal window and enter the following:
sudo apt update
Install OpenJDK 8 with:
sudo apt install openjdk-8-jdk
Alternatively, install version 11:
sudo apt install openjdk-11-jdk
You’ll be asked to confirm the download and installation. Press Y and hit Enter, then allow the process to finish.

Step 2: Install Jenkins

1. To install Jenkins on Ubuntu, use the following commands:
sudo apt update
sudo apt install jenkins
2. The system prompts you to confirm the download and installation. Press Y and hit Enter, and the system downloads and installs Jenkins. 3. To check Jenkins was installed and is running enter:
sudo systemctl status jenkins
You should see a bright green entry that says active (exited). This means the service is running. 4. Exit the status screen by pressing Ctrl+Z.

Step 3: Modify Firewall to Allow Jenkins

You need to open Port 8080 to allow Jenkins to communicate. If you’re using the default UFW firewall, enter the following:
sudo ufw allow 8080
sudo ufw status
If you’re using a different firewall application, follow its specific instructions to allow traffic on Port 8080. In the default UFW, if you haven’t configured the firewall it displays as inactive. You can enable UFW using the following:
sudo ufw enable

Step 4: Set up Jenkins

1. To launch and set up Jenkins, open a web browser, and navigate to the IP address of your server:
http://ip_address_or_domain:8080
Use the actual IP address or domain name for the server you’re using Jenkins on. For example, if you're running locally, use:
http://localhost:8080
2. You should see a page that prompts you to Unlock Jenkins. You’ll need the default password. You can get the default password by switching to a command line and entering the following:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
3. The system returns an alphanumeric code. Enter that code, then click Continue. 4. Next, you are prompted to either Install suggested plugins or Select plugins to install. It’s fine to simply install the suggested plugins. You can always install more plugins later. The system continues the initial Jenkins setup. 5. Then you will be prompted to Create First Admin User. Enter the credentials you want to use for your Jenkins administrator, then Save and Continue. 6. After this, you should set up the Instance Configuration. This is the preferred network address for this Jenkins installation. Confirm the address you want to use for your server. This is most likely the same address you used to get to this configuration page. When you’re satisfied, click Save and Finish. 7. You should see a page that says Jenkins is ready! You can click Start using Jenkins to open the Jenkins dashboard.

Conclusion

You should now have a working installation of Jenkins on your Ubuntu system.
       

Advertisements

ads