2. What is Continuous integration
A development methodology
Of daily developer integrations
Verified by automated builds
Every commit triggers a build
As soon as you have completed an independent functionality
A full build on another, empty machine
3. Why use continuous integration
Automate the build
Make the build self testing
Keep the build fast
Test in a clone of the production environment
Everyone can see what's happening
Automate deployment
4. Self-testing build
Directly go from source to running build
No manual copying
No click on dialog boxes
No configuration file editing
Test with
Unit tests
Functional tests (web tests)
Performance tests
Responsible persons should be notified when
anything fails
Tests web in more browsers
5. Why Jenkins?
● Continuous integration server - detects changes
in Subversion, performs tasks, repeatedly.
(Build, Test, Deploy, Test, Package)
● Seven years old approx
● 47000+ installations
● 600+ plugins
● Free !!!!!!
7. Configuration as Code
• Define jobs/pipelines as code
• Avoid point & click
• In version control
• Can live with the application
• Scales better
• Example: .travis.yml (from TravisCI)
• Similar to GitlabCI
8. Job Pipelines
●Job - a unit of work for a project
You can chain jobs together in a pipeline.
Promotion occurs when a job succeeds
Then the next job in the pipeline executes
(based on some conditions)
9. Jenkins Pipeline Plugins
• Whole suite of plugins (10+), open-sourced in 2016
• Shipped with Jenkins 2.0
• Formerly commercially available by CloudBees, called Work
• Define pipeline as code (again Groovy DSL)
10. Pipeline as code
• Introduce “Pipeline” as a new type in Jenkins
• Codify an implicit series of stages into an explicit pip
• Resumability/durability of pipeline state
• Extend the DSL to meet organizational needs
11. Jenkins Job DLS Steps
Jenkinsfile describe pipeline using Jenkins Pipeline DSL
Jenkins Pipeline DSL consist of steps like:
stage: starts a new pipeline stage
node: executes steps on an agent (node) with the
corresponding name / label
checkout: checkouts code from SCM (e.g. Git or SVN)
sh: executes command line or shell script
bat: executes Windows command line or script
junit: publishes JUnit test results
14. Plugins that support Pipeline
• A few plugins which provide custom steps for Pipeline scripts:
- Tooling: Credentials binding, SSH Agent, Parallel Test
- Reporters: JUnit, Brakeman, HTML Publisher, Cucumber Test
- Notifiers: Slack, HipChat, email-ext
- Wrappers: Timestamper
• Plugins work within Pipelines
- SCM: Git, SVN, Mercurial, P4, CV
- Wrappers: Ansi Color, NodeJS
- Build steps: Ant, etc
15. Parallel Execution of Steps
parallel(
//Both deployments are executed in parallel
deployToEnv1: {
node('environment-1') {
deploy(…)
}
},
deployToEnv2: {
node(environment-2') {
deploy(…)
}
}
)
//Execution continues after the longer step
finishes
16. Use existing plugins in pipeline
It is possible to use existing Jenkins Plug-ins if they added Pipeline support
Majority of popular Jenkins plug-ins support Pipeline already (see list here)
E.g. Email-Ext plug-in:
emailext(
subject: "Build #$buildNumber, $status",
recipientProviders:'CulpritsRecipientProvider'
…
)
17. Docker Support
Jenkins Pipeline also provides Docker support
See Orchestrating Workflows with Jenkins and Docker
docker.image('.../java8-maven').inside {
checkout svn
sh 'mvn -B clean install'
}
19. Blue Ocean Plugin
Jenkins will soon get a new UI optimized for pipelines:
Blue Ocean – see the following slides
It can be installed from the experimental update center:
http://updates.jenkins-ci.org/experimental/update-
center.json
New UI –Blue Ocean