How can I install Jenkins on CentOS 7?. Jenkins is an open source automation server written in Java that was designed to automate repetitive tasks that are often encountered in continuous integration and delivery of software. Jenkins is typically run as a standalone application in its own process with the built-in Java servlet container/application server (Jetty).
Minimum Hardware requirements:
- 256 MB of RAM, 1 GB+ recommended
- 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
For Ubuntu, see: How to Install Jenkins on Ubuntu
For Arch Linux: How to Install and Configure Jenkins on Arch Linux
For Docker Container: Running Jenkins Server in Docker Container with Systemd
Step 1: Install Jenkins on CentOS 7
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 -y install epel-release sudo yum install java-1.8.0-openjdk
Check to make sure that you have java installed by running:
$ java -version openjdk version "1.8.0_201" OpenJDK Runtime Environment (build 1.8.0_201-b09) OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
Start by importing the repository key from Jenkins:
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
After importing the key, add the repository to the system:
sudo yum -y install wget sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
Then install Jenkins package using
sudo yum -y install jenkins
If you need the LTS release only, run the following commands instead:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum -y install jenkins
You can now start Jenkins service using:
sudo systemctl start jenkins sudo systemctl enable --now jenkins
A check on status should return running state
$ sudo systemctl status jenkins ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) Active: active (exited) since Thu 2019-03-07 09:23:25 CET; 4s ago Docs: man:systemd-sysv-generator(8) Process: 15039 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) Mar 07 09:23:24 centos-2gb-nbg1-1 systemd: Starting LSB: Jenkins Automation Server… Mar 07 09:23:25 centos-2gb-nbg1-1 runuser: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Mar 07 09:23:25 centos-2gb-nbg1-1 jenkins: Starting Jenkins [ OK ] Mar 07 09:23:25 centos-2gb-nbg1-1 systemd: Started LSB: Jenkins Automation Server.
8080/tcp on the firewall:
sudo firewall-cmd --add-port=8080/tcp --permanent sudo firewall-cmd --reload sudo firewall-cmd --list-all
The service should be listening on port
$ sudo ss -tunelp | grep 8080 tcp LISTEN 0 50 :::8080 :::*
Step 2: Unlock Jenkins on CentOS 7
Browse to the URL
http://[serverip|hostname]:8080 to access web installation wizard.
When you first access a new Jenkins instance, you are asked to unlock it using an automatically generated password.
Get the password from
$ cat /var/lib/jenkins/secrets/initialAdminPassword
Copy-paste the automatically-generated alphanumeric password into the Administrator password field and click Continue.
Next is to create an admin user account used to manage the Jenkins server.
Select plugins to install in the next page.
Step 3: Configure Nginx and SSL (Optional)
It is recommended to access Jenkins Server behind a Proxy server secured with SSL certificate. Check below guide.
Step 4: Configure User Roles on Jenkins
By default, Jenkins user policy allows logged in users to access anything. This should not be the case and you need to set proper user policies. Check out our Jenkins policy and user management guide below.
Let other users Login with their credentials and assign them roles which define what they can do on Jenkins server.
Enjoy automating your jobs with Jenkins. For more reading, check Official Documentation. We will publish more articles on Jenkins and CI/CD.