CI with jenkins
CI with jenkins
CI with jenkins
Continuous Integration is a software development practice where members of a team integrate their
work frequently, usually each person integrates at least daily - leading to multiple integrations per day.
Each integration is verified by an automated build (including test) to detect integration errors as quickly
as possible.
You need a tool to create a CI enabled environment. Jenkins, Travis CI, Bamboo,Buildbot are different
tools available to enable CI.
In this course, you will be learning about Jenkins, a widely used open source CI tool, written in Java.
Jenkins was earlier referred to as Hudson. Jenkins was primarily developed by Kohsuke Kawaguchi.
Features of Jenkins
Easy to install
Permanent links - Jenkins provides direct links to the latest or failed build, which can be used for easy
communication
Pre Jenkins:
Bugs identified during testing in the source code, should be fixed and then re-tested
Post Jenkins :
Once code change is committed,Jenkins automatically takes care of the build , test and reporting of
results.
Jenkins Plugins Index provides you the various plugin options such as:
Build Tools: In large projects use a build manager such as Maven or Ant.
Reporting: Jenkins provides its own reports. It can be extended using tools like Static Analysis Collector
that collects the different analysis results and shows it in a combined trend graph.
Plugins can be configured via the Manage Plugins under Manage Jenkins.
For setting up a new project in Jenkins , following sections are to be planned and configured as required:
Triggering Build - Control when Jenkins will perform builds by Polling, Periodic or Build based on other
projects
Email notifications
It consists of five fields separated by white space, indicating respectively the minute (0–59), hour (0–23),
day of the month (1–31), month (1–12) and the day of the week (0–7, with 0 and 7 being Sunday).
star is a wildcard character which accepts any valid value for that field.
“* 9-17 * * *” means every minute of every day, between 9am and 5pm.
A weather icon (on the home page dashboard) - shows you a record of multiple builds
A colored ball (on the individual project page) - shows you status of a single build
Status has corresponding tooltips with explanations , when you hover over it.
Setting up Jenkins CI Pipeline
In the Katacoda exercise, you would have learnt how to use jenkins and docker in the CI pipeline.
Pre-Requisites
Plugins to install
You should be able to create the first two jobs easily. Below steps will help you to create the deploy job.
Jenkins provides a host of plugins for unit testing such as Junit and Mstest for .Net unit tests..
In Test Report XMLs field, enter location of result xml files produced by executing Junit test cases
Jenkins is open to every one. So, anyone can access Jenkins and perform all available tasks that were
discussed previously.
It provides settings for security and role management - useful for controlling access and defining user
actions.
Choose jenkins own user database to maintain your own user database.
For a central administrator to define other users in the system, unselect Allow users to signup and save.
What if, as part of a large project, you need to build codes and report results regularly ?
Running all the builds on a centralised machine would not be the best option.
What if, you need to automatically test the code in various environments ?
Master-Slave architecture
Jenkins uses Master - Slave architecture for managing distributed builds. In master node, you need to
install Jenkins. While it can also execute build jobs, it handles all related tasks for build system -
Master-Slave Communication
To operate, master and slave will establish bi-directional communication link like TCP/IP
In the next window, enter details like the IP address and the user credentials
On completion of the steps mentioned in the previous card, the new node machine will be online and
ready .
Select 'Restrict where this job can be run' option under your 'project configuration`
In Jenkins, all build logs, archives, configuration settings are stored under the Jenkins home directory.
If you choose to use the backup plugin, you need to trigger backup manually
If full backup of home directory is not needed, use ThinBackup plugin to backup specific details, like jobs,
configuration, build history.
Secure Jenkins.
Schedule jobs ensuring not all jobs are executed at the same time.