In this article, we will have explained the necessary steps to install and configure Jenkins on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Jenkins is a popular open-source CI (Continuous Integration) tool which is widely used for project development, deployment, and automation.
Jenkins is written in JAVA language a currently focusing on two main purposes:
- Building and testing software projects, just like CruiseControl or DamageControl. Jenkins provides an easy-to-use continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases productivity.
- Monitoring executions of externally-run jobs, such as cron jobs, even those that are run on a remote machine. Jenkins keeps those outputs and makes it easy for you to notice when something is wrong.
Install Jenkins on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo yum install epel-release sudo yum update
Step 2. Install Java.
Jenkins requires Java in order to run, but CentOS 7 doesn’t include it by default. To install the Open Java Development Kit (OpenJDK) run the following:
sudo yum install java-1.8.0-openjdk-devel
After installing Java you can verify it by running the following command:
Step 3. Install Jenkins.
The next step is to enable the Jenkins repository. To do that, import the GPG key using the following curl command:
curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
And add the repository to your system:
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
Now install the Jenkins package using yum:
sudo yum install jenkins
After the installation process is completed, start the Jenkins service with:
sudo systemctl start jenkins sudo systemctl enable jenkins
In order to allow visitors access to Jenkins, you need to allow inbound traffic on port 8080:
sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp sudo firewall-cmd --reload
Step 4. Setting up Jenkins.
For start setting up our Jenkins, we need to visit its web dashboard running on port 8080. so open your browser and see your public IP address or your Domain name followed by the port number through it:
When you first access a new Jenkins instance, you are asked to unlock it using an automatically generated password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You should see an 32 character long alphanumeric password:
Copy the password from your terminal, paste it into the Administrator password field and click Continue:
Next, click on the Install suggested plugins box, and the installation process will start immediately:
Once the installation is complete, you will be prompted to set up the first administrative user.
Congratulation, you have learned how to install and configure Jenkins on CentOS 7. If you have any question, please leave a comment below.