|

How to Install Jenkins on Linux: Step-by-Step Guide [2021]

Share On

Are you looking to install Jenkins on your Linux system? Jenkins is a popular open-source automation server that allows you to automate various tasks, including building, testing, and deploying software. In this step-by-step guide, we will walk you through the process of installing Jenkins on Linux. Whether you are a developer, a system administrator, or someone interested in learning about continuous integration and automation, this article is worth reading.

1. Update the system packages

Before installing Jenkins, it is important to ensure that your system packages are up to date. This will help you avoid any compatibility issues and ensure a smooth installation process. To update the system packages, open the terminal and run the following command:

sudo apt update && sudo apt upgrade

This command will update the package lists and upgrade any installed packages to their latest versions.

2. Install Java Development Kit (JDK)

Jenkins is built on Java, so you need to have Java Development Kit (JDK) installed on your system. To install JDK, run the following command:

sudo apt install default-jdk

This command will install the default version of JDK available in your Linux distribution’s package repository.

3. Add the Jenkins repository key to the system

In order to install Jenkins, you need to add the Jenkins repository key to your system. This key is used to verify the authenticity of the Jenkins packages. To add the key, run the following command:

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

This command will download the Jenkins repository key and add it to your system.

4. Add the Jenkins repository to the system’s package sources

Next, you need to add the Jenkins repository to the package sources on your system. This will allow your system to fetch the Jenkins packages from the repository. To add the repository, run the following command:

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

This command will create a new file called “jenkins.list” in the “/etc/apt/sources.list.d/” directory and add the Jenkins repository URL to it.

5. Update the package lists

After adding the Jenkins repository, you need to update the package lists on your system. This will ensure that your system can find the Jenkins packages. To update the package lists, run the following command:

sudo apt update

This command will fetch the latest package information from all the repositories configured on your system.

6. Install Jenkins

Now that you have added the Jenkins repository and updated the package lists, you can proceed with the installation of Jenkins. To install Jenkins, run the following command:

sudo apt install jenkins

This command will download and install the Jenkins package on your system.

7. Start the Jenkins service

Once the installation is complete, you can start the Jenkins service. To start the service, run the following command:

sudo systemctl start jenkins

This command will start the Jenkins service on your system.

8. Enable Jenkins to start on system boot

If you want Jenkins to start automatically every time your system boots up, you can enable the Jenkins service. To enable the service, run the following command:

sudo systemctl enable jenkins

This command will configure the Jenkins service to start on system boot.

9. Access Jenkins through the web browser

Now that Jenkins is up and running, you can access it through a web browser. Open your favorite web browser and enter the following URL:

http://localhost:8080

This will take you to the Jenkins web interface.

10. Unlock Jenkins by retrieving the initial administrator password

When you access Jenkins for the first time, you will be prompted to unlock it by entering the initial administrator password. To retrieve the password, run the following command:

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

This command will display the initial administrator password on the terminal. Copy the password and paste it into the Jenkins web interface to unlock Jenkins.

11. Install suggested plugins or select custom plugins

After unlocking Jenkins, you will be presented with the option to install suggested plugins or select custom plugins. The suggested plugins include a set of commonly used plugins that can help you get started with Jenkins. You can choose to install these plugins or select custom plugins based on your requirements.

12. Create an admin user and provide necessary details

Once the plugin installation is complete, you will be asked to create an admin user for Jenkins. Provide the necessary details, including username, password, full name, and email address. This admin user will have full control over Jenkins and can configure and manage the Jenkins server.

13. Start using Jenkins for continuous integration and automation

Congratulations! You have successfully installed Jenkins on your Linux system. You can now start using Jenkins for continuous integration and automation. Jenkins provides a wide range of features and plugins that can help you automate your build, test, and deployment processes. Explore the Jenkins documentation and start configuring your Jenkins jobs to automate your software development workflow.

In conclusion, installing Jenkins on Linux is a straightforward process that involves updating system packages, installing JDK, adding the Jenkins repository, and installing Jenkins itself. Once installed, Jenkins can be accessed through a web browser, and you can unlock it by retrieving the initial administrator password. After unlocking Jenkins, you can install plugins, create an admin user, and start using Jenkins for continuous integration and automation.

Frequently Asked Questions

1. Can I install Jenkins on any Linux distribution?

Yes, Jenkins can be installed on any Linux distribution as long as it meets the system requirements. The installation process may vary slightly depending on the package manager used by the distribution.

2. Can I use Jenkins for non-Java projects?

Absolutely! While Jenkins is built on Java, it can be used for projects written in any programming language. Jenkins provides a wide range of plugins that support various programming languages and tools.

3. Can I run Jenkins on a remote server?

Yes, Jenkins can be installed and run on a remote server. In fact, running Jenkins on a dedicated server is a common practice to ensure optimal performance and availability.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *