Configuration As Code: The Job DSL Plugin

2,964 views

Published on

An introduction the Job DSL plugin for the Jenkins continuous integration server. Learn how to treat job and view configuration as code, how to store the configuration in SCM and how to apply code reuse and refactoring. Learn how to extend the Job DSL for your favorite plugins.

Published in: Software, Technology, Business

Configuration As Code: The Job DSL Plugin

  1. 1. Jenkins User Conference Europe #jenkinsconf Configuration As Code The Job DSL Plugin Daniel Spilker CoreMedia www.coremedia.com June 25, 2014 #jenkinsconf
  2. 2. Jenkins User Conference Europe #jenkinsconf Current Situation • No single job that builds everything • Each branch needs its own pipeline • Every team has their own jobs
  3. 3. Jenkins User Conference Europe #jenkinsconf Problem • Lots of copy&paste • Editing in HTML text areas • Settings hidden behind Advanced button • Working with the UI can be slow
  4. 4. Jenkins User Conference Europe #jenkinsconf Configuration As Code • Create new pipelines quickly • Refactor jobs • Trace changes • Work with your favorite tool set
  5. 5. Jenkins User Conference Europe #jenkinsconf There Is A Plugin For That • Template Project Plugin • Job Generator Plugin • Literate Plugin • JobConfigHistory Plugin • … • Job DSL Plugin Open Icon Library / CC BY 3.0
  6. 6. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  7. 7. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  8. 8. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  9. 9. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  10. 10. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  11. 11. Jenkins User Conference Europe #jenkinsconf Job DSL Language job { name('job-dsl-plugin-folders') scm { github('daspilker/job-dsl-plugin', 'folders') } triggers { githubPush() } steps { gradle('clean build') } publishers { archiveArtifacts('**/job-dsl.hpi') } }
  12. 12. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  13. 13. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  14. 14. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  15. 15. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  16. 16. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  17. 17. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  18. 18. Jenkins User Conference Europe #jenkinsconf Job DSL Plugin • Install Job DSL Plugin • Create free-style project • Add “Source Code Management” • Add “Process Job DSL” build step • Configure scripts • Run job
  19. 19. Jenkins User Conference Europe #jenkinsconf Batteries Included EnvInject Groovy Copy Artifact Git Subversion Folders Extra Columns StashNotifier Maven Deployment Linker Gradle Build Pipeline Workspace Cleanup GitHub Pull Request Builder GitHub Multiple SCMs JaCoCoRelease Build Flow Robot Framework Tool Environment Conditional BuildStep Throttle Concurrent Builds Associated Files JSHint Checkstyle Emma Xvnc Prerequisite Build Step AnsiColor Timestamper Text-Finder Job DSL Perforce Ant Maven Project
  20. 20. Jenkins User Conference Europe #jenkinsconf Extending The DSL
  21. 21. Jenkins User Conference Europe #jenkinsconf Extending The DSL
  22. 22. Jenkins User Conference Europe #jenkinsconf Extending The DSL job { ... configure { project -> project / buildWrappers << EnvInjectPasswordWrapper { injectGlobalPasswords(true) } } }
  23. 23. Jenkins User Conference Europe #jenkinsconf Everything is Groovy @Grab(…) … gitHub.user('daspilker').repos.each { repo -> repo.branches.each { branch -> job { name("${repo.name}-${branch.name}") scm { github(repo.name, branch.name) } … } } }
  24. 24. Jenkins User Conference Europe #jenkinsconf Further Information • Documentation https://github.com/jenkinsci/job-dsl-plugin/wiki • Examples https://github.com/sheehan/job-dsl-gradle-example • Playground http://job-dsl.herokuapp.com/ • Mailing List https://groups.google.com/forum/?fromgroups#!forum/job-dsl-plugin
  25. 25. Jenkins User Conference Europe #jenkinsconf Corporate Community Thank You To Our Sponsors Platinum Gold Silver
  26. 26. Jenkins User Conference Europe #jenkinsconf Thank You Daniel Spilker daniel.spilker@coremedia.com @daspilker We‘re hiring www.coremedia.com @CoreMediaMinds

×