Jenkins 2.x Chris Vogel
Agenda O Jenkins background O Installation O Jenkins 2.x highlights O Build pipelines O Pipeline DSL O Multibranch plugin
Jenkins O An open source continuous integration tool O Extensible with over 1000 plugins O Master/agent architecture O Released weekly (currently 2.17) O Has quarterly LTS releases (2.7.2)
History O Originally released in February 2005 as Hudson O Forked in February 2011 as Jenkins O Released version 2.0 on April 20, 2016
Installation O Download WAR file O Run as executable WAR file O Install in web container (e.g. Tomcat) O Run as Docker container O jenkins – LTS release O jenkinsci/jenkins – weekly release
Installation O Native installations O Debian-based distribution O apt-get O Red Hat-based distribution O yum O Windows O Master and agents as Windows service
Setup Wizard O Initializes security O Requires initial, generated, admin password O Allows creation of admin account O Plugin configuration O Suggested plugins O Manual selection
Setup Wizard Demo
Jenkins 2.x Highlights O Focused more on continuous delivery O Pipeline DSL O Maintains backwards compatibility O Improved job configuration screens O Tab metaphor O Improved “New Item” screen O Same interface
New UI (Blue Ocean) O Re-thinks the Jenkins user experience O A separate UI O Old and new side-by-side O Currently in alpha
Build Pipeline “Automated manifestation of your process for getting software from version control into the hands of your users”
Example Project O Baseball Standings O Spring Boot O Gradle O JUnit O Jacoco O Docker O Selenium O MySQL
Example Pipeline O Checkout O Build/Test O Publish test results & code coverage O Sonar code analysis O Create Docker image O Run system tests
Build Pipeline O Legacy Pipeline (Jenkins 1.x) O Chain individual jobs together
Build Pipeline O Legacy Pipeline (Jenkins 1.x) O Chain individual jobs together O Build Pipeline Plugin View
Legacy Pipeline Demo
Build Pipeline O New Pipeline (Jenkins 2.x) O Pipeline DSL O Pipeline as code O In job vs in SCM
Pipeline DSL O Groovy-based Domain Specific Language O Extensible by plugins O Extensible by Pipeline Global Library O Web-based snippet generator O IntelliJ IDEA GroovyDSL downloadable script
Pipeline as Code O Design a whole pipeline, not a linear set of tasks O Store the pipeline configuration (Jenkinsfile) in a text file in SCM O Automatically set up new pipelines when configuration files are added O Differentiate multiple branches in the same repository
Pipeline Goals O Complex requirements - fork/join, loop, parallel O Resilient – survive master restarts O Pausable – pause and wait for human input O Efficient – restart from saved checkpoints (Enterprise) O Visualized – Pipeline StageView dashboard
Pipeline Vocabulary O Step O A single task/build step O Stage O Grouping of logical build steps O Node O Schedules build steps on a build agent O Creates a workspace
Pipeline DSL Steps O build: Build a job O checkout: General SCM O echo: Print message O git: Git O input: Wait for interactive input O mail: Mail O node: Allocate node
Pipeline DSL Steps O sh: Shell script O stage: Stage O step: General build step O tool: Use a tool from a predefined tool installation
DSL Global Variables O env: Environment variables O scm: SCM configuration, multibranch or script from SCM O docker: Docker-related functions O Build images O Manage images O Run containers
Jenkins 2.x Pipeline Demo
Multibranch Job O Enables configuration of jobs for branches of a project O Automatically discovers branches O Requires a Jenkinsfile in the project root
Multibranch Job Demo
Resources O Website - O Getting Started with Pipeline O Pipeline Tutorial - plugin/blob/master/TUTORIAL.md plugin/blob/master/TUTORIAL.md O Plugin Compatibility with Pipeline - plugin/blob/master/COMPATIBILITY.md plugin/blob/master/COMPATIBILITY.md
Resources O Continuous Deliver with Jenkins Workflow and Docker - stories.com/blog/2015/08/23/continuous- delivery-with-jenkins-workflow-and-docker/ stories.com/blog/2015/08/23/continuous- delivery-with-jenkins-workflow-and-docker/ O Introducting Blue Ocean - g-blue-ocean/ g-blue-ocean/ O My Jenkinsfile - Jenkins2 Jenkins2