What is Jenkins? Jenkins is a well-known open source CI/CD (Continuous Integration and Continuous Delivery) automation server written in Java.
In this tutorial i will show how to install Jenkins on Ubuntu-18.04, 16.04 and Centos-7, 6 and how to perform initial Jenkins configuration.
Jenkins requires Java, so firstly it needs to install OpenJDK-8 JRE/JDK (Java Runtime Environment and Java Development Kit).
Jenkins requires Java and if it is not installed you may receive an error as follows:
ERROR: No Java executable found in current PATH:
Found an Incorrect Java Version? Modern versions of Jenkins require Java 8 and it is the ONLY supported runtime environment.
Check if Java is installed and what is the version:
$ java -version
Install OpenJDK-8 JRE/JDK on Ubuntu:
$ sudo apt-get update $ sudo apt-get install openjdk-8-jdk openjdk-8-jre
Install OpenJDK-8 JRE/JDK on CentOS:
$ sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
Install Jenkins on Ubuntu
Install the latest stable Jenkins version on Ubuntu:
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - $ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' $ sudo apt-get update $ sudo apt-get install jenkins
As only Jenkins is installed on Ubuntu, it will be started and added to auto-start automatically.
Install Jenkins on CentOS
Install the latest stable Jenkins version on CentOS:
$ sudo curl -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 install jenkins
On CentOS, Jenkins is configured to start on boot automatically, but by default it is stopped.
To start the Jenkins, run:
$ sudo service jenkins start
By default, Jenkins listens on port
http://$JENKINS_IP:8080 in your web-browser to start configuration.
To unlock Jenkins and sign in it will be required to copy and paste the password that has been written to the file
/var/lib/jenkins/secrets/initialAdminPassword on Jenkins server.
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword ea0e27bb08cd497c86a3777121c8b967
After unlocking Jenkins, select plugins to install, create administrative user and configure URL that will be used to access Jenkins.
Now you are ready to start using Jenkins!