Activities

August 2013
M T W T F S S
« Jul   Sep »
 1234
567891011
12131415161718
19202122232425
262728293031  

Jenkins : How do I setup Continuous Integration server

Jenkins is an award-winning application that monitors executions of repeated jobs, such as building a software project or jobs run by cron.

Major role of Jenkins is,

1. Building/testing software projects continuously, just like CruiseControl or DamageControl. In a nutshell, Jenkins provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.

2. Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that are run on a remote machine. For example, with cron, all you receive is regular e-mails that capture the output, and it is up to you to look at them diligently and notice when it broke. Jenkins keeps those outputs and makes it easy for you to notice when something is wrong.

Hardware and Software Requirements.

1. XEON Server type processor
2. RAM : More than 2GB depending on number of Jobs
3. Disk : More than 100GB (depending on project size)
4. JDK 1.6 or later Apache Web server for setting up reverse proxy(Optional)

Installing Jenkins

Jenkins is a Java web application and we can deploy standalone war file on any J2EE supported web servers like Tomcat, Jetty etc. Here I’m going to install it on Amazon Linux AMI (62 bit platform) which having 1.7GB RAM and single computing unit. All 64 bit Linux AMI (CentOS6) can be scale up easily in case of any resource conjunction happens in future.

Installing Jenkins on AWS Linux AMI

Jenkins website support yum type installation for RedHat/CentOS platforms. This type installation is fairly simple and easily. Steps involved are a, download repo information file, update the system yum repository and install the package from the remote Jenkins server. Here are the command to go,

[root@localhost installation]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg. jenkins-ci.org/redhat/jenkins.repo
[root@localhost installation]# rpm --import http://pkg.jenkins-ci.org/redhat/jen kins-ci.org.key
[root@localhost installation]# yum install jenkins
you will need to add Jenkins in system start up inorder to start automatically in case of system reboot occurs.
[root@localhost installation]# chkconfig jenkins on

How did I start Jenkins service

[root@localhost installation]# service jenkins start

1

Once you start the Jenkins service, you can access Jenkins url at http://localhost:8080

2

Enable website authentication on Jenkins

Jenkins allows admin access to everyone by default. So we need to put authentication in it. It does support realm authentication such as LDAP, Unix authentication and Jenkins own user authentication. I prefer Jenkins own user authentication as it is completely independent. First we need to enable user registration on Jenkins prior to setup Jenkins own authentication.

Here we go,

Go to the menu Jenkins–> Manage Jenkins –> Global security then choose “enable security“. This will show you different authentication mechanism and choose “Jenkins own authentication” and enable “allow users to signup“. Then click on apply button to save the changes.

Note : Don’t forget tot disable allow users to sign up as soon as you create an initial admin account.

    Because Jenkins allow users to read all the settings default.

So we need to disable as soon as the required users are created once.

3

Now you can see sign in options are enabled at the top right side of the portal. Then create an admin user and set all privileges to this admin user.
4

You need to set privileges to that user as soon as you create a new user. You can set permission in Jenkins–> Configure Global Security and under the authorization section choose Matrix based security and set proper permission to that user.

Next time Jenkins will ask you user credentials to sign in as security is enabled. See the screen shown below,

5

Installing Git Plugins

In order to access Git repository from Jenkins, we may need to enable Git plugins in jenkins installs. Plug-ins install can be done easily through the Jenkins UI. To do that we may navigate the menu Jenkins–> Manage Plugins and click on “available” menu. It will display all the Jenkins support plugins listed there. Search and find Git plugin out there, Put a tick on “Git Client Plugin” and install. Don’t forget to click on “install without reboot“.Once you had installed it successfully you see the Git option button shown in you project under the version control menu as shown below,

6

The above Git checkout url uses SSH private key authentication. So you need to import your private key under “Jenkins –> Manage Credentials –>SSH username with Private Key” So that any access from the Jenkins server towards any server/service will be authorized based on this keystore file. So it will not prompt any password anymore during the deployment script runs.

Eg: If you want Jenkins to deploy the files to a web server A, we may need to import the serverA file in this area. So that Jenkins can access the serverA without any password and deploy the files when build started. You may review the key later either by opening the same window or updating the ~/.ssh/authorized_keys file directly.

7

8

3. Enabling Email alerts and installing advanced Email report plugins.

Jenkins is providing email alert mechanism which will send alert emails whenever there is a build status changes. Unfortunately default email notification does not bring you more detailed report including whether a build is started, stopped or executed successfully. There is a email plug-ins which has lots of customization for email output named as “Email-ext plugin“. You can installed it easily using the “manage Plugins” window and installing steps are similar to other plugin installs. Once you had installed it, you can see certain additional options are enabled there.

There are two major configuration of this plugins,

1. System wide settings
2. Job wise settings.

a. System wide settings

In this area you may need to define smtp account details, default senders address and default recipient list. Email-ext plugins uses this values to send email in job wise settings.
We should fill up the following fields
a. Default user E-mail suffix [Here we are using Amazon SES smtp which is permit to send email only from liju@serveridol.com address. So default system admin address should be same.

b. Default system admin email address : liju@serveridol.com
c. SMTP username and password
d. SMTP port and SSL/TLS support.

Rest of the fields are optional. But any values on this text boxes will be used later as application variables ($DEFAULT_RECIPIENTS) from your jobs.
9

b. Job wise settings

To enable this option you may navigate to choose your job-–> configure then click on “add post build action” then choose the email notification and editable email notification.
This settings can be set project wise. So that we can define only responsible person whocan receive the build alert and notifications. Most of the field shown in the following screen are editable. Here we can define the email header name, Subject name, set recipient list, set email content and can attach the build log etc. We may use trigger mechanism to set the timing of email delivery.

123
We can create any number of project and classify the build according to the project nature in Jenkins interface. There are 3 type of project in Jenkins

a. Build a free-style software project { Most popular}
This is the central feature of Jenkins. Jenkins will build your project, combining any SCM with any build system, and this can be even used for something other than software build.

b. Build a maven2/3 project
Build a maven 2/3 project. Jenkins takes advantage of your POM files and drastically reduces the configuration.
c. Build multi-configuration project
Suitable for projects that need a large number of different configurations, such as testing on multiple environments, platform-specific builds, etc.

d. Monitor an external job
This type of job allows you to record the execution of a process run outside Jenkins, even on a remote machine. This is designed so that you can use Jenkins as a dashboard of your existing automation system
Let us choose the option A for our projects. To start a new project, Navigate the menu Jenkins–> New jobs and then type your project name and choose Build a free-style software project. This will create a new job in jenkins and you can see some sub menus are associate with your projects. Those menus are,

a. Changes : This is a build description area that we can add prior to start a new build against new release or fix
b. Workspace : This is the version checkout folder once the SCM pool is trigger. We will manipulate the files and folders from this point to build production ready deployment folders.
c. Build now : Option for triggering build manually
d. Delete project : Delete the current job
e. This option will open available configuration setting associate with the current job
f. SCM pooling log: Details information about the SCM changes can be viewed here.

11

Now you navigate Jenkins–> Jobs –> Configure and start to fill out the Email and SCM settings.

1. You need to configure the SCM access details on your jobs. If you wish to use git repo, you need to add the public keys in “Manage credential” area.
2. Set proper email recipients those who gets email whenever build status is changed. It’s also possible to include our custom message on this area.

The above steps will helpful to configure a Jenkins project easily.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>