Install and configure Jenkins on RedHat 6

 

 

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Logo.jpg

Jenkins is an opensource and most popular continuous integration tool written in Java. There are many plugins are available to make it more easier. It supports almost all version control systems. You can configure builts with various means like, triggered by a commit in a version control system, scheduling by cron-jobs, built after a specific built completes etc.. 

 

In this article will talk about Jenkins Installation (1) Résumé and (2) detailed.

 

 

1) Installation Résumé:

[root@dev-rdsjenkins ~]# service jenkins start

Starting Jenkins                                           [  OK  ]

[root@dev-rdsjenkins ~]#

  • netstat -tnlp | grep 8080    #verify the default Jenkins starting Port 8080
  • Log file is placed in /var/log/jenkins/jenkins.log.
  • /etc/sysconfig/jenkins will capture configuration parameters for the launch.
  • Web Links

    http://dev-rdsjenkins:8080/

 

2) Installation Detailed:

In this article I will show you how to install and configure Jenkins on RedHat 6, CentOS 6.4.

Step – 1

To install and configure Jenkins on CentOS we have to first install JAVA on the machine. Below are the steps to install JAVA on CentOS.

Verify the java by issuing the below command

Now we will add Jenkins Repository to our machine.

Now we will Install Jenkins

Add Jenkins to system boot

Start Jenkins

By default Jenkins will start on Port 8080. You can verify that with the below command.

Go to your browser and type http://localhost:8080/. Now you should able to see the Jenkins dashboard like below image.

https://i0.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Dashboard-1.jpg

Step – 2

Now we will setup Authentication for Jenkins. By default Jenkins allows “Anyone can do anything.”. Here we will setup Matrix based security authentication. For this follow the below steps:

Click on Manage Jenkins > Configure Global Security > Jenkins Own User Database > Allow Users to Signup > Save

https://i0.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-User-Signup-Config.jpg

 

Step – 3

After saving the above step then follow the below step to create an user:

Click on Signup button (Top right corner of the dashboard) > Fill all the required information > click on SignUp (Below the Form)

https://i0.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Signup-form.jpg

Step – 3

Now we will restrict User Signup and add “Matrix based security authentication”. Please follow the below steps:

Click on Manage Jenkins > Configure Global Security > Jenkins Own User Database > Unchek “Allow Users to Signup” > Matrix-based security > Put the user Name @ “User/group to add:” text box > click on add > Check all the Check boxes > Save

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Matrix-Authentication-Setup.jpg

Now onwards User “Tapas Mishra” can administrate Jenkins after login. Also you can add more user to the db by following the below

Step – 4

Click on Manage Jenkins > Manage Users > Create Users

After this follow the Step – 3 again to add previliage to the new user.

 

 

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Logo.jpg

 

I will describe about how to configure nodes on Jenkins. Nodes are the servers where we will deploy our applications. You can configure n number of Nodes in your Jenkins applications depending on the server capacity.

Before configuring a node we have to add there credential first. Like user name and password for the node if the node is passwordbased authentication enabled. Else you can add the user name and private key if the node is passwordless authentication enabled.

How to add credentials.

Log in to your Jenkins account. Click on the credential tab as shown in the below image.

https://i1.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Credential-1.png

 

 

Now Click on “Add domain” as shown in the below image.

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Credential-2.png

 

 

Provide a user friendly name and some description to it and press “OK”

https://i1.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Credential-3.png

 

 

Now Click on “Add Credentials” tab then provide your information as shown in the below image.

https://i0.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-Credential-4.png

 

 

After completing the Credential entry in the Jenknins now we will add the Node.

How to add Node on Jenkins.

Go to the main dashboard of Jenkins Click on “Manage Jenkins” > Click on “Manage Nodes” from the List.

You will find a Node named “Master” in the node list which is the Jenkins server itself.

To add a new node click on “New Node”. Enter the information and click on as shown in the below image.

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-AddNode-1.png

 

 

Now enter all the information about your host as shown in the below Image. Click on the advance and modify your port number if you are using any different port for your SSH.

https://i0.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-AddNode-2.png

 

 

It will take some time to Lunch the new node and then you will able to see the information about the node in your Jenkins Dashboard. See the below image.

https://i2.wp.com/www.linuxfunda.com/wp-content/uploads/2013/11/Jenkins-AddNode-3.png

 

 

 

We will see how to configure a job on Jenkins. Basically the job will deploy an application from Github on a configured node. We will configure a simple Job in this part. We will just clone a github repository in a node using Jenkins. But in our later articles we will discuss about critical deployments.

We will complete this in three steps.

  • Install required Plugin
  • Configure Job
  • Build the Job and verify

Step 1 (Install required Plugin)

If we are using GIT as our Sour Code Management then we have to install plugin for it. The git plugin will help use to deploy the codes on a node. It’s very simple to configure. To install a plugin follow the steps as described below

Click on Manage Jenkins > Click on Manage Plugins > Click on Available Tab > Filter the Git Plugins > Chose the Git Plugin > Click on install without restart. > Chose Restart Jenkins when installation is complete option.

Step 2 (Configure Job)

Now we will create a Job for deploying an application on our previously configured server from github. To Create a new job Click on New Job > Give a Name to the Job > Choose “Build a free-style software project” option > Click on “Ok”

After getting the new window Check the option “Restrict where this project can be run“. You will get a text box to enter a node name where the build will be taken place (Setup a node following the steps in my previous). Write the node name in my case it’s “www.linuxfunda.com“. If you will not check this option then Jenkins will clone your repository in Master it self.

Chose the Git Radio button from the “Source Code Management” section and write the Github Repository URL. In my case it’s “ https://github.com/tapasprivate/tapasprivate.git “.  I have described how to add Credentials in a previous article. Add the appropriate credential for the github account. Specify the branch name if you want any specific branch to clone else  it will clone “master” branch of the repository. There are also other advance options are available like git submodules which we will discuss in later articles.

Step 3 (Build the Job and Verify)

Now we have done with the configuration of the job. Save the Configuration and build the job. SSH to your node where you took the build. Go to the Workspace path and verify that your files are there from github. In my next article we will configure a job with shell script.

 

 

Hope This Helps.

Wissem MEDIOUNI.

Écrire commentaire

Commentaires: 0