Jenkins – Installation and Configuration on RedHat Distributions (inc. Screenshots)

Jenkins Installation and Configuration on RedHat Distributions

Jenkins : One of the leading and most popular CI/CD tool which is currently used in most of the organisations because of its simplicity, flexibility and lot many features like ease-of-use, extensibility, cross-platforms-working, etc

The best thing about Jenkins is that its an Open-Source tool, that means you don’t have to worry about managing licenses, arranging project funds to buy it.

There are thousands of plugins developed to enhance its functionality and capability and the development is still going on by numerous individuals to make and maintain Jenkins as a best CI/CD tool.

You can find an extensive list of jenkins plugins @ https://wiki.jenkins-ci.org/display/JENKINS/Plugins

Now, lets try to install and configure Jenkins on Centos Linux 7 (Assuming you have a internet access from your linux machine, else you can follow the manual installation which is described in jenkins-ci.org)

Please note that Jenkins requires Java 7 or above. As per jenkins-ci.org, Java8 is recommended.

Jenkins also requires a fair amount of memory to operate flawlessly. Smaller installations should start around 256MB-1GB.

The first step is to setup the yum repository

To install a stable release – type

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

or to install the latest release – type

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

Screen Shot 2016-03-15 at 01.32.52

Once you place the jenkins repo inside yum repos, the next step is to import the key, to do that just type

sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

Screen Shot 2016-03-15 at 01.33.26

Then install Java through yum

Install Java through YUM - Jenkins installation and configuration

Type ‘y’ to continue

Screen Shot 2016-03-15 at 01.42.23

Once done, then install Jenkins through yum

Screen Shot 2016-03-15 at 01.46.11

Check and then Start the Jenkins service

Screen Shot 2016-03-15 at 01.47.02

You can then verify Jenkins installation and jenkins process

Screen Shot 2016-03-15 at 01.50.05

If everything looks okay, then proceed further and open Jenkins UI.

Open Browser and type http://localhost:8080

Jenkins, by default runs on port 8080. You can change the default port to other port by changing the value of below variable in file /etc/sysconfig/jenkins

JENKINS_PORT=”8080″

Note that the built-in firewall may have to be opened to access this port from other computers.  (See http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/ for instructions how to disable the firewall permanently)

Now, lets start the jenkins and do the basic configuration.

Screen Shot 2016-03-15 at 01.52.50

Once you type the URL, the default jenkins page will open, which is accessible to all the users who have access to your server.

First thing you should configure is your user-id, so that you can restrict others to play with your instance.

To do so, click on “Manage Jenkins” link available on left side bar

Screen Shot 2016-03-16 at 12.19.41

You can see the warning message about insecure Jenkins page. Click on “Setup Security” link

Screen Shot 2016-03-15 at 01.54.07

This will open the new page of “Configure Global Security”

Screen Shot 2016-03-15 at 01.54.25

Click on “Enable security” which will open new options for you to configure.

Screen Shot 2016-03-15 at 01.54.36

You can use different type of Access Controls, such as unix user/group, your organisation’s LDAP, any other servlet container or the normal Jenkins own database (Make suer you uncheck the checkbox of “Allow users to sign up” if want to control your installation)

Screen Shot 2016-03-15 at 01.55.13

You can also set up the Authorisation mode and Save it.

Once you save it, Jenkins will allow you to create one admin user so that you can start working on it.

Screen Shot 2016-03-15 at 01.55.59

You can create any user (for simplicity, i used “admin” user name)

Screen Shot 2016-03-15 at 01.56.10

Once done, it will automatically logged in as Admin user, but in case you want to check, close the browser and type the jenkins url again.

This time it will ask you to Log-in.

Screen Shot 2016-03-15 at 01.56.34

Type your credentials which you just setup.

Screen Shot 2016-03-15 at 01.56.48

Now, you can also create user-ids for other users if you wish so.

Again click on “Manage Jenkins”

Screen Shot 2016-03-16 at 01.42.38

Click on “Manage Users”

Screen Shot 2016-03-16 at 01.42.47

This will open a webpage where you can see all the available users. As you just created only one user, it will list out that user

Screen Shot 2016-03-16 at 01.42.57

Now click on “Create User” link present on left hand side bar and fill the user details accordingly

Screen Shot 2016-03-16 at 01.44.10

Once done, click on Sign-up and new user will be added to Jenkins database.

Now create a project to get started.

You can give a brief description about your project if you want.

Screen Shot 2016-03-15 at 01.59.20

You can define other options, as shown below:

Screen Shot 2016-03-15 at 01.59.56

Screen Shot 2016-03-15 at 02.00.44

If you define the build as parameterised, it will show you another option to add a new parameter

Screen Shot 2016-03-15 at 02.00.17

By default, only CVS and subversion is available as Source code management.

But don’t forget – Jenkins works with plugins and there are thousand of plugins to fulfil your requests.

In case you need any other VCS, just save this project configuration now and we will configure it later.

Screen Shot 2016-03-15 at 02.00.32

Again go to the link “Manage Jenkins”

Screen Shot 2016-03-15 at 02.06.40

Click on “Manage Plugins”

I have my code in GIT repository, so i will add git as source code management.

To achieve it, just type “git plugin” in Filter (if filter is not working you can use CTRL + F to find on the webpage)

Screen Shot 2016-03-15 at 02.07.07

Just select the relevant plugin and click on “Download now and install after restart” button

Screen Shot 2016-03-15 at 02.08.17

It will then start to download the plugin.

Screen Shot 2016-03-15 at 02.08.29

You can click on the checkbox of “Restart Jenkins when installation is complete and no jobs are running”

Screen Shot 2016-03-15 at 02.09.06

This will allow Jenkins to retstart

Screen Shot 2016-03-15 at 02.09.19

Once restarted, you can verify the new plugin in “Installed” section of “Manage Plugins”

Screen Shot 2016-03-15 at 02.11.55

You can also configure your Jenkins to utilise it perfectly

Go to “Manage Jenkins” link and click on “Configure System”

Screen Shot 2016-03-16 at 01.01.34

You can find all the configuration which your Jenkins instance requires.

Screen Shot 2016-03-16 at 01.03.10

Lets begin with updating a System message which will appears on Jenkins Dashboard. You can write any message which you want to convey to the users who would be using this Jenkins instance.

Screen Shot 2016-03-16 at 01.03.21

I just kept it short but you can write as many lines as you want and it will looks like as below :

Screen Shot 2016-03-16 at 01.24.32

Along with this you can define many things, such as you can define the default retry count of SCM checkout like below

Screen Shot 2016-03-16 at 01.03.47

You can also tell the Jenkins where should it finds different installations, such as JDK, ANT, GIT, Maven, etc

Screen Shot 2016-03-16 at 01.05.23

You can also define the Jenkins URL and system admin’s email address which Jenkins will use for notifying errors

Screen Shot 2016-03-16 at 01.05.41

You can also configure the mail server and then Jenkins will send out the mails to the user as per your configuration.

Its an useful and essential step to configure mail notification in case of passed or failed builds to notify the user so that they can fix it promptly.

I’ve used the basic server’s mail server, but you can define the whole SMTP settings through Advanced tab.

You can test the configuration by providing an email address and check your mail box, you will receive an email from Jenkins

Screen Shot 2016-03-16 at 01.17.11

Once done, just Save your changes.

Now, lets proceed and configure our project.

Go to Jenkins home page where you can see your project and click on “Configure” link on left hand side bar

Screen Shot 2016-03-15 at 02.12.49

This will open the same configuration page which we saved and left due to missing version control system.

Now, this time you can see a new “Source Code Management” tool has been added which is “Git”

Screen Shot 2016-03-15 at 02.13.05

Click on it.

It will allow you to add Git URL and the credentials if needed.

Screen Shot 2016-03-15 at 02.15.26

Once done, you can see Jenkins has fetched out the Repository from the given URL

Screen Shot 2016-03-15 at 02.16.03

You can define other repository related options which you may need during build, i selected to Clean the Jenkins area before doing a fresh checkout overtime.

Screen Shot 2016-03-15 at 02.16.26

You can also define when you want Jenkins to Poll the Source code management (the frequency of fetching/checking changes in provided VCS).

Screen Shot 2016-03-15 at 02.17.10

To get the full idea about the syntax, click on ‘?’ symbol (help page).

Screen Shot 2016-03-15 at 02.17.39

I have configured Jenkins to check the changes in every 5 mins, that means after every five minutes Jenkins will check and verify the Version control system and fetch out the new changes (if any)

Screen Shot 2016-03-15 at 02.18.31

Once SCM is configured, you need to tell Jenkins about the build step, how you want Jenkins to build this project

Screen Shot 2016-03-15 at 02.20.05

I selected to execute Shell scripts. Jenkins will now ask you to mention the script name along with the path to execute during build

Note that, you need to change the user to “jenkins” for both script directory path and script, so that Jenkins can find and execute the script when needed

Screen Shot 2016-03-16 at 00.37.45

Screen Shot 2016-03-16 at 00.16.28

You can find several inbuilt variables which you can use as a parameter to your script through the help page

Screen Shot 2016-03-16 at 00.10.13

Once done, you can also define any post build activities which you might require on build completion

I selected to achieve a file.

Screen Shot 2016-03-16 at 00.18.42

You can find more relevant options inside Advanced tab

Screen Shot 2016-03-16 at 00.19.05

I selected an option to “Archive the artifacts only if build is successful”

Screen Shot 2016-03-16 at 00.19.15

Once done save all your changes. Jenkins will automatically triggers the first build for you.

In case you need to trigger, just open your project and click on “Build Now” link located at left bar.

Now go to the dashboard.

Screen Shot 2016-03-16 at 00.27.39

Click on Build number located at left bar under “Build History”, in my case #1.

It will open the Build page which will gives you the stats of your build.

Screen Shot 2016-03-16 at 00.26.33

Click on Console Output to see the build log.

Screen Shot 2016-03-16 at 00.26.45

Congratulations !! You have successfully done the basic Jenkins configuration and built your first project.

In today’s article we have covered:

  • Jenkins installation
  • User creation
  • Jenkins Project creation
  • Managing Jenkins Plugins
  • Adding new VCS to Jenkins through plugin
  • Jenkins system basic configuration
  • E-mail notification configuration
  • Build creation

In Next article, we will configure Jenkins Master-Slave architecture.

12 thoughts on “Jenkins – Installation and Configuration on RedHat Distributions (inc. Screenshots)”

  1. I don’t even know the way I finished up here, but I believed this put up used to be great.

    I don’t recognize who you are but certainly you’re going to a famous blogger if you aren’t already.

    Cheers!

  2. excellent submit, very informative. I wonder why other experts on this sector don’t notice this. You must continue your writing. I am just sure, you’ve a massive readers’ base already!

  3. Hi to every body, it’s my first go to see of this webpage; this web site carries awesome and genuinely excellent stuff for readers.

  4. Very good information. Lucky me I came across your site by accident (stumbleupon).
    I’ve book marked it for later!

  5. Great post. I was checking continuously this blog and I’m impressed!
    Extremely helpful information specially the last part 🙂 I care for such information a lot.

    I was seeking this certain information for a long time.
    Thank you and best of luck.

Leave a Reply to Ed Cancel Reply

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top