JUC West ’15: Jenkins Workflow: What’s Up?

25
Jenkins Workflow: What’s Up? Jesse Glick (@tyvole) CloudBees

Transcript of JUC West ’15: Jenkins Workflow: What’s Up?

Jenkins Workflow: What’s Up?Jesse Glick (@tyvole)

CloudBees

#jenkinsconf

What is Workflow?

2

Footer

#jenkinsconf

Why?

3

Footer

#jenkinsconf

Scriptable builds

• Entire build/deploy pipeline in one legible script• Groovy script calls pluggable steps to:

• grab Jenkins slaves• check out sources• run external build tools• launch other jobs• wait for approval• …much more

• Build can survive a Jenkins restart4

#jenkinsconf

Improvements since 1.0

5

Footer

#jenkinsconf

Monthly releases

• load whole script from SCM• improved build step useful for migrating to Workflow• better handling of environment variables• non-concurrent builds• stash & retrieve files• various smaller fixes and enhancements

6

Footer

#jenkinsconf

Plugin compatibility

• More SCMs: CVS, Perforce, RTC• Gerrit, BitBucket, GitLab, GitHub (in progress)• Analysis publishers, HTML Publisher, scoverage• Misc.: Parameterized Trigger, Rebuild, …• Many still outstanding, including:

• builders (sometimes can roll your own)• misc. plugin features (Shelve, …)

• Office Hour, docs for developers

7

#jenkinsconf

Features for 1.609.x LTS

8

Footer

#jenkinsconf

Build wrappers

• New wrap step• offers easy-ish compatibility for plugins

• Set environment variables, clean up, edit build log• Implementations include:

• Xvnc, Xvfb, Kubernetes, NodeJS, Timestamper, Config Files

• Mask Passwords (coming soon)• or use Credentials Binding

• Also notable: SSH Agent step9

Footer

#jenkinsconf

Better executor handling

• Safe restart while flow running• Hide flow’s master “executor” when idle• Minimize native thread usage

10

#jenkinsconf

Docker

11

Footer

#jenkinsconf

CloudBees Docker Workflow

• Simple entry point to Docker-related functions• Running builds inside a container

• replaces elaborate Jenkins slave setups• Build images from source• Run images in test containers• Push to private Docker registry

12

#jenkinsconf

Custom DSLs

13

Footer

#jenkinsconf

Defining new vars & functions

• workflowLibs.git had a src dir to define classes• now supports a vars subdirectory• scripts here can act like global variables

• create a new DSL entry point, like docker• or act as functions, if you define a call method

• like defining a new step, but in Groovy!• Groovy builder pattern also possible

• use: myThing { prop = 'value' }

14

#jenkinsconf

Multibranch

15

Footer

#jenkinsconf

• Can use branch wildcards in Git (etc.)• mixes up changelog, status, test results• no way to adjust build steps per branch

• Can create one project per branch• painful to maintain without extra tools

• Most people need this!

Why can’t Jenkins branch?

16

Footer

#jenkinsconf

Multibranch workflows

• Every branch with a Jenkinsfile → one subproject• that is your Workflow script• just checkout scm to get full source tree

• Already works with Git, Subversion, Mercurial• OSS: optimized GitHub support (in devel.)• CJP: +GitHub pull requests (in devel.)• CJP: +Stash, BitBucket, Gerrit, …

• Can edit Jenkinsfile in your branch• revision matches sources

17

Footer

#jenkinsconf

Organization scanning

• Before: custom scripting just to add all 100 repos• New folder type (in devel.): “organization”

• each item is a multibranch Workflow project• adds/removes projects automatically

• Only configuration is org name + credentials• one step closer to “code as config”

• OSS: GitHub (incl. private, GHE)• CJP: +other providers

18

Footer

#jenkinsconf

Jenkinsfile

standardBuild { environment = 'golang:1.5.0' mainScript = '''go build -v hello-world.go''' postScript = '''ls -l./hello-world'''}

19

Footer

#jenkinsconf

vars/standardBuild.groovy

def call(body) { def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config body() stage 'checkout' node { checkout body.owner.scm stage 'main' docker.image(config.environment).inside { sh config.mainScript } stage 'post' sh config.postScript }}

20

#jenkinsconf

Future directions

21

Footer

#jenkinsconf

Proposed major features

• syntax completion for IDEs & static reference• in-browser syntax highlighting, too

• Matrix Project replacement• wait/notify• more options for stage step• more load-script-from-SCM options• labeled block• link to log of failed step• “pause” button

22

Footer

#jenkinsconf

Fixes fixes fixes

• more plugin compatibility• robustness: “hard kill”, better diagnostics• more complete Groovy language support• workspace links in UI• UI tweaks, consistent documentation• >200 filed issues!• growing team at CloudBees specializing in

Workflow development

23

Jenkins World Tour 2015Santa Clara, CA, September 2-3

24

#jenkinsconf

Footer

Thanks to our Sponsors!

25