Continuous Integration (CI) is an essential process in modern software development that helps to automate the build, test, and deployment process. Jenkins is a popular open-source tool for implementing CI/CD pipelines. In this article, we’ll show you how to install Jenkins on a Linux system in a step-by-step tutorial.
Installing Jenkins on Linux
Table of Contents
- Introduction
- Prerequisites
- Install Java
- Install Jenkins
- Start Jenkins
- Configure Jenkins
- Create a Jenkins Job
- Test the Jenkins Job
- Install Jenkins Plugins
- Configure Jenkins Security
- Conclusion
- FAQs
Introduction
Jenkins is a powerful tool for automating the software build, test, and deployment. It provides a wide range of plugins that enable you to extend its functionality to meet your specific requirements. This tutorial will show you how to install Jenkins on a Linux system and configure it to create a CI/CD pipeline.
Prerequisites
Before we begin, you’ll need the following:
- A Linux-based operating system (we’ll be using Ubuntu in this tutorial).
- A user account with sudo privileges.
- Access to the internet.
Install Java
Before installing Jenkins, you need to install Java. Jenkins requires Java 8 or higher. To install Java, follow these steps:
- Update package list:
sudo apt-get update
2. Install OpenJDK:
sudo apt-get install -y openjdk-8-jdk
3. Verify that Java is installed:
java -version
You should see the version of Java that you installed printed to the console.
Install Jenkins
To install Jenkins, follow these steps:
#Add the Jenkins repository key to the system:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
#Add the Jenkins repository to the system:
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
#Update the package list:
sudo apt-get update
#Install Jenkins:
sudo apt-get install -y jenkins
#Verify that Jenkins is installed:
sudo systemctl status jenkins
You should see the status of the Jenkins service printed on the console.
Start Jenkins
To start Jenkins, follow these steps:
#Open your web browser and navigate to the following URL:
http://<your-server-ip-or-domain>:8080/
#You should see the Jenkins login screen.
#Enter the initial password, which can be found in the following file:
/var/lib/jenkins/secrets/initialAdminPassword
Follow the prompts to set up Jenkins.
Configure Jenkins
To configure Jenkins, follow these steps:
- Click on “Manage Jenkins” in the left-hand menu.
- Click on “Configure Global Security” and select “Enable Security.”
- Select “Jenkins’ user database” and create a new user.
- Set the “Authorization” option to “Matrix-based security” and add the new user with “Administer” privileges.
- Click “Save” to save the configuration.
Create a Jenkins Job
To create a Jenkins job, follow these steps:
- Click on “New Item” in the left-hand menu.
- Enter a name for the job and select “Freestyle project.” Click “OK” to create the job.
- Configure the job by adding a source code repository, specifying build triggers, adding build steps, and configuring post-build actions.
- Click “Save” to save the job configuration.
Test the Jenkins Job
To test the Jenkins job, follow these steps:
- Click on the job name in the left-hand menu.
- Click “Build Now” to start the build.
- Monitor the build progress and view the build console output for any errors.
- Once the build is complete, verify that the build artifacts have been created.
Install Jenkins Plugins
Jenkins provides a wide range of plugins that can be used to extend its functionality. To install Jenkins plugins, follow these steps:
- Click on “Manage Jenkins” in the left-hand menu.
- Click on “Manage Plugins” and select the “Available” tab.
- Search for the plugin that you want to install and select it.
- Click “Install without restart” to install the plugin.
Configure Jenkins Security
Jenkins allows you to configure security settings to restrict access to your Jenkins instance. To configure Jenkins security, follow these steps:
- Click on “Manage Jenkins” in the left-hand menu.
- Click on “Configure Global Security” and select “Enable Security”.
- Select “Jenkins’ user database” or an external user database and configure the security settings.
- Click “Save” to save the security configuration.
Conclusion
Jenkins is a powerful tool for automating the software build, test, and deployment. In this tutorial, we showed you how to install Jenkins on a Linux system and configure it to create a CI/CD pipeline. We also covered how to configure Jenkins security and install plugins. With Jenkins, you can streamline your software development process and reduce the time and effort required to build and deploy software.
FAQs
- What is Jenkins, and why is it essential for software development? Jenkins is a powerful tool for automating the software build, test, and deployment. It is essential for software development because it allows developers to streamline the development process, reduce errors, and deploy software faster.
- What operating systems does Jenkins support? Jenkins supports various operating systems, including Windows, Linux, and macOS.
- What are the system requirements for running Jenkins? The system requirements for running Jenkins depend on the size and complexity of your Jenkins instance. Generally, you’ll need at least 1 GB of RAM and a multi-core CPU.
- Can Jenkins be used for non-Java projects? Yes, Jenkins can be used for non-Java projects. It supports a wide range of programming languages and technologies.
- Is Jenkins free to use? Yes, Jenkins is an open-source tool and is free to use.
How to use Travis CI for continuous integration
How to use Jenkins for continuous integration
How to unleash the power of the AWS code pipeline
Best 10 tools for continuous integrations in DevOps