INSTALL AND CONFIGURE JENKINS ON CENTOS 7
Here, This tutorial guides you to install Jenkins on Centos 7.
Jenkins is an open source automation tool also known as the Continuous Integration tool.
Jenkins was written in JAVA language.
It is used to automate the repetitive tasks which are involved in software development process.Repetitive tasks include Software Build, Test, and Deployments.
jenkins can be installed through system packages with RPM, DEB or DOCKER machines.
Jenkins requires Java with the minimum of Java 7 version.Jenkin recommends Java 8.To install Java use the below command.
You can search for java packages,
#yum search java |grep openjdk
#yum install java-1.8.0-openjdk* wget -y
Alternatively You can install Oracle Java instead of OpenJDK.
Once the JDK installation is completed, verify the JAVA version.
openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-b12) OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
Installation of Jenkins
We have to add Jenkin’s repository to the machine as it is not available by default in Linux.
Add the Jenkins key to the system.
#rpm –import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Next, We can wget the repo file to add the Jenkins repository to the machine:
#yum install jenkins -y
Now We have to enable, start and check the status of Jenkins:
- systemctl enable jenkins
- systemctl start jenkins
- systemctl status jenkins
Add Firewall Rule
We have to configure the firewall so that we can access Jenkins Web port from outside machine:
Before that, We have to install firewalld on the machine:
#yum install firewalld -y
Start the service:
#systemctl start firewalld
Add the firewall rule to allow port 8080:
#firewall-cmd –permanent –add-port=8080/tcp
Configuration of Jenkins
By Default, For security reasons, Jenkins has its initial password in /var/lib/jenkins/secrets/initialAdminPassword to prevent Un-Authorized access.
To access the Password:
Jenkins provides Web interface where you can build Test and deploy software.Open the browser and access the Jenkins Web console using the below URL:
You will see the below-landing page, Copy and paste the Jenkins Password on the wizard to continue.
Now, You can install Suggested Plugins or you can manually install plugins based on your needs.We choose to install Suggested Plugins.
It will take some time to complete.
Now We have to create a new admin user for Jenkins to manage Jenkins Web management wizard:
Jenkins is now ready to build software.Click on “Start using Jenkins”.
Jenkins Web Portal
Create Your First Jenkins Project
Let’s create a sample build using shell command.Click create new jobs or New Item on the left to get started.
Give a new for your project and choose Freestyle project and then click OK
On Project Configuration Page, Under Build section choose Execute shell and click save and apply.
Enter a shell command to execute while building a project.
echo “This is my Test project” and then Save.
The project is now ready to build, Click on Build now in the left pane to build the project.
You will see the following output.
That’s All. You have successfully installed Jenkins on Centos 7.