DevOps Cours Jenkins

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

Module

Intégration
Continue
History

▪ In 2004, appearance of Hudson, an open source continuous integration solution


developed by Sun MicroSystems

▪ After a conflict (the use of the name Hudson by Oracle), in November 2010, proposal to
rename the project to Jenkins

▪ In February 2011, Oracle decided to continue to develop Hudson. Jenkins is considered a


fork of Hudson

▪ Today Jenkins is the only survivor!


What is Jenkins

▪ Jenkins is an open-source Continuous Integration server written in Java for


orchestrating a chain of actions to achieve the Continuous Integration process in an
automated fashion.

▪ Jenkins supports the complete development life cycle of software from building, testing,
deploying the software.

▪ Jenkins is a feature Rich Application, which help organization in fast s/w delivery.
What is Jenkins

CI / CD solution written in Java and allowing:


▪ Automate builds and tests by configuration or scripting.
▪ Monitor the construction phases of projects
▪ To build and deploy on remote instances (master / salve)
▪ To be able to easily obtain the binaries of the latest stable versions

Solution not specific to Java projects. Ability to use Jenkins with many languages
(javascript, php, .net, c / c ++, swift ...)
What is Jenkins

▪ Code Built and Test as soon as Developer Commit the Changes.

▪ Auto Deployment on Successful Software Build and Notify Stakeholders.

▪ Notify Errors to Development team on Build Failure.

▪ Automating Build Process saving the Delivery Time and reduce the Defects.
What is Jenkins

• Des centaines de plugins disponibles.

• Facilement extensible

• Possibilité de définir finement des droits d’accès par projet


Why Jenkins
Let us imagine, that there are around 10 developers who are working on a shared repository. Some developer
completes their task in 25 days while others take 30 days to complete.

Before Jenkins After Jenkins


The code is built and test as soon as
Developer commits code. Jenkin will
Once all Developers had completed
build and test code many times during
their assigned coding tasks, they used
the day
to commit their code all at same time.
If the build is successful, then Jenkins
Later, Build is tested and deployed.
will deploy the source into the test
Code commit built, and test cycle was
server and notifies the deployment
very infrequent, and a single build was
team.
done after many days.
If the build fails, then Jenkins will notify
the errors to the developer team.
Why Jenkins

Before Jenkins After Jenkins


Since the code is built after each
It is not an easy task to isolate,
commit of a single developer, it’s
detect, and fix errors for multiple
easy to detect whose code caused
commits.
the built to fail
Code build and test process are
Automated build and test process
entirely manual, so there are a lot of
saving timing and reducing defects.
chances for failure.
The code is deployed once all the The code is deployed after every
errors are fixed and tested. successful build and test.
The development cycle is fast. New
Development Cycle is slow features are more readily available to
users. Increases profits.
Who Use Jenkins
Jenkins Key Terminology

• Job: is the definition of an executable task or a structure to organize our Jenkins


projects.

• View & Folder: Are options in Jenkins used to regroup jobs by category depending on
what structure you want to work on.

• Extension & Plugin: are the primary means of enhancing the functionality of a Jenkins
environment to suit the user-specific needs. can be installed on jenkins to provides
multiple new fonctionnalities on (build tool, test tool, cloud providers, analyse tool..etc)
Jenkins Key Terminology

• Master: is the Jenkins main server coordinating processes such as configuration


storage, plugin management, and UI display.

• Agent: is a slave machine orchestrated by the master in order to  balance the


workload between nodes and executes tasks en parallel

• Dashboard: is a simple and powerful place where we can manage all jobs and
therefore manage the application delivery pipeline as well
Jenkins Key Terminology

• Pipeline: is an automated expression of your process for getting software from version control
right through to your users and customers. enable you to define the whole jobs workflow based
on script written with DSL (domain-specific language)
Jenkins Key Terminology
Jenkins Dashboard
PROJECT VIEW
PROJECT VIEW
WORKSPACE
JOB/pipeline Creation ▪ A build start based on the trigger configuration

▪ Broken builds are usually treated as a high


priority issue and are fixed quickly.

▪ If build is OK then automated code quality and


code coverage metrics are now run along with
unit tests to continuously evaluate the code
quality.

▪ Automated Deployment
JOB Creation
JOB Creation

2
JOB
Creation

• Environment variables
Source Code • Workspace cleaning
Trigger build Build envirenment
importation rules
• Configure output
• SCM Remote trigger results
which SCM ?
• Following another build
• Periodically build
• Periodically check on SCM

• Scripts Maven,
• Exporting repports gradle, ant
• Send of notifications Post-build actions Build Scripts
• Scripts shell, Ansible,
(Email, Slack..) Python..
• Deployment actions
JOB Trigger

VS
General
• Nombreuses extensions
Ex : Récupération des
branches / tags Git / SVN

• Définition de liste de
valeur, checkbox, saisie
manuelle

• Paramètres exploitable
dans les scripts de build
Source Code Management
Build Triggers
For all scheduling tasks, Jenkins uses a cron-style syntax, consisting of five fields separated by white space in the
following format:

MINUTE HOUR DOM MONTH DOW


with the following values possible for each field:

MINUTE
Minutes within the hour (0–59)

HOUR
The hour of the day (0–23)

DOM
The day of the month (1–31)

MONTH
The month (1–12)

DOW
The day of the week (0–7) where 0 and 7 are Sunday.
There are also a few short-cuts:

“*” represents all possible values for a field. For example, “* * * * *” means “once a minute.”

You can define ranges using the “M–N” notation. For example “1-5” in the DOW field would mean “Monday to
Friday.”

You can use the slash notation to defined skips through a range. For example, “*/5” in the MINUTE field would
mean “every five minutes.”

A comma-separated list indicates a list of valid values. For example, “15,45” in the MINUTE field would mean “at 15
and 45 minutes past every hour.”

You can also use the shorthand values of “@yearly”, “@annually”, “@monthly”, “@weekly”, “@daily”,
“@midnight”, and “@hourly”
Build Environment

• Allow the injection of environment variable into this particular job


• Workspace cleaning rules
• Configure output results
• Error handling
Build
Post-Build actions
Result Dashboard TU / Coverage

Access
Configuration /
Modification

Builds history
• Possibility to see the workspace

Tip: it is better to remove it in the Post Build


phase

=> May take up a lot of space


(Example : node_modules > 400 Mo per
build)
Rapport des Tests Unitaires Progress of the passage of TU

Status of TU by packages
/ by TU
Allows you to easily determine
problems during compilation and
correct
Statistiques par classes

Couverture par ligne


Jobs

LABS:
• lab1_jenkins.txt
• lab2_jenkins.txt
• lab3_jenkins.txt
• lab4_jenkins.txt

You might also like