1 of 42

Jenkins Pipeline

2 of 42

3 of 42

About us

Michaël Pailloncy

Baptiste Mathus

  • Software Developer & Automation addict
  • DevOps Automation/Tools Engineer
  • OSS contributor

​

  • Passionate about Agile, Devops & Continuous Delivery, and all things Automation
  • Jenkins & MojoHaus Committer
  • Lengthy-reply generator�
  • Software Developer @

​

​

4 of 42

Continuous Delivery

5 of 42

Continuous Delivery

Extends Continuous Integration best practices to production

Goals :

  • Reduce feedback loop as much as possible
  • Release and deploy as often as possible, as fast as possible
  • Visibility of the pipeline state for all teammates

​

6 of 42

Each commit* = Deployable artifact to any environment

*or logical group of commits

7 of 42

What are commits unreleased to production?

8 of 42

What are commits unreleased to production?

9 of 42

Reduce chunk size

Release Early, Release Often

10 of 42

Bring confidence over deployment process

11 of 42

Repeatable and reliable

​

Same process, same tools on each environment

12 of 42

Bring confidence over artifact quality

​

​

13 of 42

Bring confidence over artifact quality

Automation

​

14 of 42

A human decision is required before deploy to production

​

=> Business decision

15 of 42

Continuous Delivery

!=

Continuous Deployment

16 of 42

http://blog.crisp.se/2013/02/05/yassalsundman/continuous-delivery-vs-continuous-deployment

17 of 42

There is no difference between theory and practice.

In practice there is.

Yogi Berra

18 of 42

Continuous Delivery - Not that easy ...

​

  • Organizational and cultural change
  • Lack of tests automation
  • Business context / customers preferences
  • Differences in target environments

​

​

19 of 42

Continuous Delivery - Not that easy ...

​

How to describe how my code goes �from commit to production?

20 of 42

21 of 42

Continuous Delivery - Not that easy ...

​

How to implement this in a �readable and robust manner?

22 of 42

Jenkins Pipeline*

* formerly known as Workflow [Plugin]

23 of 42

Jenkins Pipeline Plugin(s)

  • Set of Jenkins plugins
  • DSL to describe how to build your software
  • Resolves some limitations with classic/freestyle jobs
  • Everything As Code

24 of 42

Jenkins Pipeline Plugin(s)

  • Simple, but can do complex things : Fork/Join, loop, parallel
  • Resilient => survives to master restart
  • Pausable => human approval
  • Viewable => stage views

​

​

​

25 of 42

Workshop overview

26 of 42

Workshop resources

​

​

​

  • Go https://github.com/ToulouseJAM/workshop-resources
  • For each attendee :
    • 1 Jenkins master with :
      • All Jenkins Pipeline plugins installed
      • http://<YOUR_JENKINS_IP>:8080/ with username/password provided
    • Dynamic Jenkins agents provisioning from DigitalOcean cloud
    • 1 SonarQube instance
    • 1 “staging” environment
    • 1 “production” environment

27 of 42

Workshop #1

Jenkins Pipeline Basics

28 of 42

Scripted Pipeline vs Declarative Pipeline

  • Scripted Pipeline
    • Very powerful (too powerful ?)
    • Ideal choice for power-users
    • Handles more complex requirements
    • Imperative programming

​

  • Declarative Pipeline
    • More “formal” and strict syntax
      • Less is more? :-)
    • Syntax checking
    • Ideal for simpler pipeline and better readability
    • (only ~6 months old, but evolving at high speed)

​

​

29 of 42

Jenkins Declarative Pipeline (1/2)

30 of 42

Jenkins Declarative Pipeline (2/2)

31 of 42

Pipeline As Code - Jenkinsfile

  • Jenkinsfile = Pipeline script inside your project SCM
    • Versioned
    • Same project lifecycle

​

  • Multibranch job type :
    • Indexes all branches of a target SCM repository
    • Creates a job dedicated to each branch with a Jenkinsfile
    • Listens to all branches and triggers a build if modifications are detected
    • Notifies GitHub/BitBucket of build state

​

​

32 of 42

GitHub Organization & BitBucket Team/Project job types

  • Kind of super Multibranch job types :
    • Indexes all branches of all repositories of a GitHub Organization/Account or BitBucket Team/Project
    • And then, same as Multibranch for each project matching specified criterias

​

​

33 of 42

BlueOcean

34 of 42

BlueOcean

  • Set of Jenkins Plugins
  • Very cool new UI of Jenkins
  • Currently in beta version

35 of 42

36 of 42

Workshop #2

Pipeline As Code

37 of 42

Global Shared Library

38 of 42

Shared libraries

@Library(“my-shared-repository”)

Permits to reuse some part of code

DRY

SCM repository with some conventions :

Optionally implicitly loaded

(library step available since 2.7, �released March, 3rd 2017)

​

39 of 42

Example

40 of 42

Workshop #3

Deployment

41 of 42

Conclusion

  • Jenkins Pipeline is very powerful
  • KISS !!!
  • Need more and better documentation => but PR are always welcome :-)
  • How to test Pipeline ?
    • https://github.com/lesfurets/JenkinsPipelineUnit

​

42 of 42

Questions ?