SlideShare a Scribd company logo
Larry cai <larry.caiyu@gmail.com>
Agenda
 Introduction
 Exercise 1: Run the example to know the power
 Exercise 2: Hello World – first DSL
 Exercise 3: One complete JobDSL
 Exercise 4: JenkinsView and Loop
 Exercise 5: Configure Block to extend DSL
 Reference
2 08/12/15
Environment Preparation (docker)
 Boot2docker Installer (127M)
 Contains latest docker already, fast
 Container persistence via disk automount on /var/lib/docker
 $ docker -v
 User/Passwd: docker/tcuser (192.168.59.103)
 Download Jenkins JobDSL docker images
 $ docker pull larrycai/jenkins-jobdsl
 Notepad++ & MobaXterm are recommended
3 08/12/15
http://boot2docker.io/
Introduction
 Jenkins is a de-facto CI standard used for lots of products
 Easy to start, configure and extending (300+ plugins)
 Configure jobs in UI mostly
 Weak parts:
 Update git repo for many jobs
 Create dozens of jobs in fly for new project
 Monitor the changes
4 08/12/15
Learn new way to configure jenkins Jobs
Exercise 1: Hello World
 Run first app inside docker environment
$ cd /c/<Users>/codingwithme/jobdsl # create in advance
$ docker run -it –v $PWD:/opt/jenkins/data/jobs/jobdsl/workspace -p
8080:8080 larrycai/jenkins-jobdsl
 Browse: http://192.168.59.103:8080
Clean jenkins UI with one Job “HelloWorld”
 Exercise :
1. Execute job “HelloWorld”, and check result
2. See configuration
3. Run it again
4. Delete job “Compile-DSL-Tutorial-0” and Update job “Package-DSL-
Tutorial-0” and Run it again
5 08/12/15
JobDSL is Groovy based
 DSL : Domain Specific Language, easy to read and
understand
 JobDSL is jenkins plugin, https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin
 Groovy based
6 08/12/15
• Groovy is a multi-faceted
language for the Java
platform
• Groovy used in jenkins to
access internal data
JobDSL & Idempotent
 JobDSL helps to simplify the maintenance of jenkins jobs
 An idempotent operation is one that can be applied
multiple times without changing the result beyond the
initial application
 Keep the environment stable, reliable
 No matter the job is changed by someone, if the jobDSL
script is run, it will reach to the desired status
7 08/12/15
Exercise 2:Hello World
 Configure “HelloWorld” job
 Replace script like below
freeStyleJob("Hello2") {
steps {
shell('echo "Hello Larry"')
}
}
 Select option “Action for removed jobs” to “Delete”
and option “Action for removed views” to “Delete”,
Run it again
8 08/12/15
Jenkins Job mapping to JobDSL
9 08/12/15
 Job Type (freeStyleJob)
 Build Parameters (parameters)
 SCM (scm)
 BuildTriggers (triggers)
 Steps (steps)
 Post Build Actions (publishers)
https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference
Exercise 3: Complete JobDSL example
 Follow the existing Jenkins job “Sample” and convert it into
JobDSL in “jobdsl”
 Cover Scm/trigger/shell/archive
 Steps:
 New job “jobdsl” (freestyle)
 New build step – Process Job DSLs
 Choose “Look on Filesystem”
 complete.groovy
 In file, use freeStyleJob(“Hello3”)
 Edit it in Windows env. (codingwith/jobdsl) # mapped into docker
 Compare the result
10 08/12/15
Reference: https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference
Jenkins View & Groovy DSL
 JenkinsView is simple as jobs
 Name/filter/column .
 Learn some groovy to handle
common tasks
 Loop
 Read & Parse external config files
11 08/12/15
Exercise 4: List View and Loop
 Create different ListView and generate multi jobs based
on the config file
 Based on HelloWorld Example for jobs
 Json file: HelloWorld/workspace/views.json
 Steps
 Create new view.groovy
 Run inside job jobdsl
12 08/12/15
Configure block
 Not every jenkins Plugin are supported in JobDSL (may
changes in the future)
 Raise issues to get support
 Configure blocks are used inside the Job DSL to give
direct access to underlying XML of the Jenkins config.xml
13 08/12/15
https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block
Exercise 5: Configure Block for testNG
 Change the Sample job to export testNG result, which is
not support by jobDSL yet.
 Steps:
 Configure Sample job to publish testNG result in post-build
 Check generate config.xml
http://localhost:8080/view/CodingWithMe/job/Sample/config.xml
 Write testng.groovy based on complete.groovy
 Generate job Hello5
 Compare result
14 08/12/15
Summary
 JobDSL is the powerful to simplify the maintenance of
your jenkins jobs and keep it in professional way
 Put jobDSL scripts in git repo
 What we learn
 Execute JobDSL in jenkins jobs
 Inside script & script file
 Create job/View in jobDSL
 Simple Groovy knowledge to handle loop/read external data
 Configure Block in jobDSL to handle not direct supported
plugins
15 08/12/15
Reference
 jobDSL slides
 http://www.slideshare.net/daspilker/configuration-as-code-the-job-dsl-plugin
 JobDSL ref
 https://github.com/jenkinsci/job-dsl-plugin/wiki/View-Reference
 https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference
 https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block
 Groovy Json
 http://www.groovy-lang.org/json.html
 Exercise Gist
 https://gist.github.com/larrycai/aeb9a3b037dcb17df9b2
16 08/12/15
CodingWithMe
 "CodingWithMe - Learning by Coding" is a coding
workshop, it aims to learn one technology in 90
minutes by practice
 Features:
 4-5 well tuned hands on exercises in 90 minutes
 First exercise shall be started in 20 minutes
 It well follows Bob Pike’s 90/20/8 rules (happen to
know)
 It is recommended arranged for several parallel
sessions if it is organized in the company.
17 08/12/15
http://www.larrycaiyu.com/blog/2014/03/18/codingwithme_introduction/

More Related Content

What's hot (20)

PPTX
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Fwdays
 
PPTX
Zero to Continuous Delivery on Google Cloud
James Heggs
 
PDF
Testing with Docker
toffermann
 
PDF
Building an Extensible, Resumable DSL on Top of Apache Groovy
jgcloudbees
 
PDF
Git 101: Git and GitHub for Beginners
HubSpot
 
PDF
GlassFish Embedded API
Eduardo Pelegri-Llopart
 
PDF
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
ZeroTurnaround
 
PDF
Containerizing a Web Application with Vue.js and Java
Jadson Santos
 
PDF
JCConf 2015 workshop 動手玩 Java 專案建置工具
謝 宗穎
 
PDF
(Declarative) Jenkins Pipelines
Steffen Gebert
 
PDF
Continuous Delivery Pipeline with Docker and Jenkins
Camilo Ribeiro
 
PDF
Jenkins 101: Getting Started
R Geoffrey Avery
 
PDF
Deploying an application with Chef and Docker
Daniel Ku
 
PDF
Jenkins Pipelines
Steffen Gebert
 
PDF
JavaOne 2016 - Pipeline as code
Bert Jan Schrijver
 
PDF
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Oleg Nenashev
 
PPT
Python virtualenv & pip in 90 minutes
Larry Cai
 
PDF
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
Development Seed
 
PPTX
Baking docker using chef
Mukta Aphale
 
PPTX
Pipeline as code - new feature in Jenkins 2
Michal Ziarnik
 
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Fwdays
 
Zero to Continuous Delivery on Google Cloud
James Heggs
 
Testing with Docker
toffermann
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
jgcloudbees
 
Git 101: Git and GitHub for Beginners
HubSpot
 
GlassFish Embedded API
Eduardo Pelegri-Llopart
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
ZeroTurnaround
 
Containerizing a Web Application with Vue.js and Java
Jadson Santos
 
JCConf 2015 workshop 動手玩 Java 專案建置工具
謝 宗穎
 
(Declarative) Jenkins Pipelines
Steffen Gebert
 
Continuous Delivery Pipeline with Docker and Jenkins
Camilo Ribeiro
 
Jenkins 101: Getting Started
R Geoffrey Avery
 
Deploying an application with Chef and Docker
Daniel Ku
 
Jenkins Pipelines
Steffen Gebert
 
JavaOne 2016 - Pipeline as code
Bert Jan Schrijver
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Oleg Nenashev
 
Python virtualenv & pip in 90 minutes
Larry Cai
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
Development Seed
 
Baking docker using chef
Mukta Aphale
 
Pipeline as code - new feature in Jenkins 2
Michal Ziarnik
 

Viewers also liked (20)

PPTX
Configuration as Code: The Job DSL Plugin
Daniel Spilker
 
PDF
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Justin Ryan
 
PPTX
8 lessons learned from becoming agile
Marko Taipale
 
PDF
OpenStack Introduction Ecosystem
NUTC, imac
 
PDF
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
msohn
 
PDF
Jenkins Best Practices Meetup Slides
Gergely Brautigam
 
PDF
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
msohn
 
PDF
Group Development
Roman Keller
 
PPT
Write book in markdown
Larry Cai
 
PDF
So, you want to be a plugin developer?
ylefebvre
 
PPTX
Intégration continue
Klee Group
 
PDF
Introduction to ci with jenkins
Eric Hogue
 
PDF
Lcu14 Lightning Talk- NGINX
Linaro
 
PDF
Introduction to OpenStack : Barcamp Bangkhen 2016
Opsta
 
PPTX
Learn nginx in 90mins
Larry Cai
 
PPTX
Job DSL Plugin for Jenkins
Niels Bech Nielsen
 
DOCX
Askep kelompok cempaka
Etika Nurasih
 
PDF
The top 5 things planners need to know about self-driving vehicles
Chris Hedden
 
PPTX
Dr Chris Stout Getting Better at Private Practice
Dr. Chris Stout
 
PPT
綻放的
unotour
 
Configuration as Code: The Job DSL Plugin
Daniel Spilker
 
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Justin Ryan
 
8 lessons learned from becoming agile
Marko Taipale
 
OpenStack Introduction Ecosystem
NUTC, imac
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
msohn
 
Jenkins Best Practices Meetup Slides
Gergely Brautigam
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
msohn
 
Group Development
Roman Keller
 
Write book in markdown
Larry Cai
 
So, you want to be a plugin developer?
ylefebvre
 
Intégration continue
Klee Group
 
Introduction to ci with jenkins
Eric Hogue
 
Lcu14 Lightning Talk- NGINX
Linaro
 
Introduction to OpenStack : Barcamp Bangkhen 2016
Opsta
 
Learn nginx in 90mins
Larry Cai
 
Job DSL Plugin for Jenkins
Niels Bech Nielsen
 
Askep kelompok cempaka
Etika Nurasih
 
The top 5 things planners need to know about self-driving vehicles
Chris Hedden
 
Dr Chris Stout Getting Better at Private Practice
Dr. Chris Stout
 
綻放的
unotour
 
Ad

Similar to Learn jobDSL for Jenkins (20)

PDF
The Job DSL Plugin: Introduction & What’s New
Daniel Spilker
 
PDF
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
CloudBees
 
PPTX
Jenkins Job DSL plugin
Nikita Bugrovsky
 
PDF
Take control of your Jenkins jobs via job DSL.
Łukasz Proszek
 
PPTX
Configuration As Code: The Job DSL Plugin
Daniel Spilker
 
PDF
CICD Pipeline configuration as a code
Grid Dynamics
 
PDF
Super Charged Configuration As Code
Alan Beale
 
PDF
Jenkins JobDSL - Configuration as code
tomasnorre
 
PDF
Cultivating the jenkins job jungle with groovy - Patrick van Dissel
NLJUG
 
PDF
Rule jenkins with configuration as code
Christian Rasp
 
PDF
Brujug Jenkins pipeline scalability
Damien Coraboeuf
 
PPTX
Gluecon 2018 JaC
Brian Mericle
 
PDF
Getting out of the Job Jungle with Jenkins
Sonatype
 
PPTX
Jenkins presentation
Valentin Buryakov
 
PDF
Building dsl using groovy
Puneet Behl
 
PDF
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Alvin Huang
 
PPTX
Jenkins as a Service - Code all the way down
Steve Mactaggart
 
PPTX
Jenkins2 - Coding Continuous Delivery Pipelines
Brent Laster
 
PDF
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
PROIDEA
 
PPTX
Jenkins Pipeline 101 and TCI - presentation and workshop
Yoram Michaeli
 
The Job DSL Plugin: Introduction & What’s New
Daniel Spilker
 
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
CloudBees
 
Jenkins Job DSL plugin
Nikita Bugrovsky
 
Take control of your Jenkins jobs via job DSL.
Łukasz Proszek
 
Configuration As Code: The Job DSL Plugin
Daniel Spilker
 
CICD Pipeline configuration as a code
Grid Dynamics
 
Super Charged Configuration As Code
Alan Beale
 
Jenkins JobDSL - Configuration as code
tomasnorre
 
Cultivating the jenkins job jungle with groovy - Patrick van Dissel
NLJUG
 
Rule jenkins with configuration as code
Christian Rasp
 
Brujug Jenkins pipeline scalability
Damien Coraboeuf
 
Gluecon 2018 JaC
Brian Mericle
 
Getting out of the Job Jungle with Jenkins
Sonatype
 
Jenkins presentation
Valentin Buryakov
 
Building dsl using groovy
Puneet Behl
 
Codifying the Build and Release Process with a Jenkins Pipeline Shared Library
Alvin Huang
 
Jenkins as a Service - Code all the way down
Steve Mactaggart
 
Jenkins2 - Coding Continuous Delivery Pipelines
Brent Laster
 
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
PROIDEA
 
Jenkins Pipeline 101 and TCI - presentation and workshop
Yoram Michaeli
 
Ad

More from Larry Cai (17)

PPTX
Learn kubernetes in 90 minutes
Larry Cai
 
PPT
Learn RabbitMQ with Python in 90mins
Larry Cai
 
PPT
Learn flask in 90mins
Larry Cai
 
PPT
Learn ELK in docker
Larry Cai
 
PPT
Software Engineer Talk
Larry Cai
 
PPT
Learn basic ansible using docker
Larry Cai
 
PPT
Build service with_docker_in_90mins
Larry Cai
 
PPTX
Learn docker in 90 minutes
Larry Cai
 
PPT
Learn Dashing Widget in 90 minutes
Larry Cai
 
PPT
Learn REST API with Python
Larry Cai
 
PPT
Jenkins Scriptler in 90mins
Larry Cai
 
PPT
Lead changes in software development
Larry Cai
 
PPT
Python in 90mins
Larry Cai
 
PDF
Practical way to experience of Specification by Example
Larry Cai
 
PPT
Experience from specification_by_examples
Larry Cai
 
PPT
Continuous Integration Introduction
Larry Cai
 
PDF
Agile & ALM tools
Larry Cai
 
Learn kubernetes in 90 minutes
Larry Cai
 
Learn RabbitMQ with Python in 90mins
Larry Cai
 
Learn flask in 90mins
Larry Cai
 
Learn ELK in docker
Larry Cai
 
Software Engineer Talk
Larry Cai
 
Learn basic ansible using docker
Larry Cai
 
Build service with_docker_in_90mins
Larry Cai
 
Learn docker in 90 minutes
Larry Cai
 
Learn Dashing Widget in 90 minutes
Larry Cai
 
Learn REST API with Python
Larry Cai
 
Jenkins Scriptler in 90mins
Larry Cai
 
Lead changes in software development
Larry Cai
 
Python in 90mins
Larry Cai
 
Practical way to experience of Specification by Example
Larry Cai
 
Experience from specification_by_examples
Larry Cai
 
Continuous Integration Introduction
Larry Cai
 
Agile & ALM tools
Larry Cai
 

Recently uploaded (20)

PDF
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
AWS Chicago
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PDF
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
PDF
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PPTX
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
AWS Chicago
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Top Managed Service Providers in Los Angeles
Captain IT
 
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 

Learn jobDSL for Jenkins

  • 2. Agenda  Introduction  Exercise 1: Run the example to know the power  Exercise 2: Hello World – first DSL  Exercise 3: One complete JobDSL  Exercise 4: JenkinsView and Loop  Exercise 5: Configure Block to extend DSL  Reference 2 08/12/15
  • 3. Environment Preparation (docker)  Boot2docker Installer (127M)  Contains latest docker already, fast  Container persistence via disk automount on /var/lib/docker  $ docker -v  User/Passwd: docker/tcuser (192.168.59.103)  Download Jenkins JobDSL docker images  $ docker pull larrycai/jenkins-jobdsl  Notepad++ & MobaXterm are recommended 3 08/12/15 http://boot2docker.io/
  • 4. Introduction  Jenkins is a de-facto CI standard used for lots of products  Easy to start, configure and extending (300+ plugins)  Configure jobs in UI mostly  Weak parts:  Update git repo for many jobs  Create dozens of jobs in fly for new project  Monitor the changes 4 08/12/15 Learn new way to configure jenkins Jobs
  • 5. Exercise 1: Hello World  Run first app inside docker environment $ cd /c/<Users>/codingwithme/jobdsl # create in advance $ docker run -it –v $PWD:/opt/jenkins/data/jobs/jobdsl/workspace -p 8080:8080 larrycai/jenkins-jobdsl  Browse: http://192.168.59.103:8080 Clean jenkins UI with one Job “HelloWorld”  Exercise : 1. Execute job “HelloWorld”, and check result 2. See configuration 3. Run it again 4. Delete job “Compile-DSL-Tutorial-0” and Update job “Package-DSL- Tutorial-0” and Run it again 5 08/12/15
  • 6. JobDSL is Groovy based  DSL : Domain Specific Language, easy to read and understand  JobDSL is jenkins plugin, https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin  Groovy based 6 08/12/15 • Groovy is a multi-faceted language for the Java platform • Groovy used in jenkins to access internal data
  • 7. JobDSL & Idempotent  JobDSL helps to simplify the maintenance of jenkins jobs  An idempotent operation is one that can be applied multiple times without changing the result beyond the initial application  Keep the environment stable, reliable  No matter the job is changed by someone, if the jobDSL script is run, it will reach to the desired status 7 08/12/15
  • 8. Exercise 2:Hello World  Configure “HelloWorld” job  Replace script like below freeStyleJob("Hello2") { steps { shell('echo "Hello Larry"') } }  Select option “Action for removed jobs” to “Delete” and option “Action for removed views” to “Delete”, Run it again 8 08/12/15
  • 9. Jenkins Job mapping to JobDSL 9 08/12/15  Job Type (freeStyleJob)  Build Parameters (parameters)  SCM (scm)  BuildTriggers (triggers)  Steps (steps)  Post Build Actions (publishers) https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference
  • 10. Exercise 3: Complete JobDSL example  Follow the existing Jenkins job “Sample” and convert it into JobDSL in “jobdsl”  Cover Scm/trigger/shell/archive  Steps:  New job “jobdsl” (freestyle)  New build step – Process Job DSLs  Choose “Look on Filesystem”  complete.groovy  In file, use freeStyleJob(“Hello3”)  Edit it in Windows env. (codingwith/jobdsl) # mapped into docker  Compare the result 10 08/12/15 Reference: https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference
  • 11. Jenkins View & Groovy DSL  JenkinsView is simple as jobs  Name/filter/column .  Learn some groovy to handle common tasks  Loop  Read & Parse external config files 11 08/12/15
  • 12. Exercise 4: List View and Loop  Create different ListView and generate multi jobs based on the config file  Based on HelloWorld Example for jobs  Json file: HelloWorld/workspace/views.json  Steps  Create new view.groovy  Run inside job jobdsl 12 08/12/15
  • 13. Configure block  Not every jenkins Plugin are supported in JobDSL (may changes in the future)  Raise issues to get support  Configure blocks are used inside the Job DSL to give direct access to underlying XML of the Jenkins config.xml 13 08/12/15 https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block
  • 14. Exercise 5: Configure Block for testNG  Change the Sample job to export testNG result, which is not support by jobDSL yet.  Steps:  Configure Sample job to publish testNG result in post-build  Check generate config.xml http://localhost:8080/view/CodingWithMe/job/Sample/config.xml  Write testng.groovy based on complete.groovy  Generate job Hello5  Compare result 14 08/12/15
  • 15. Summary  JobDSL is the powerful to simplify the maintenance of your jenkins jobs and keep it in professional way  Put jobDSL scripts in git repo  What we learn  Execute JobDSL in jenkins jobs  Inside script & script file  Create job/View in jobDSL  Simple Groovy knowledge to handle loop/read external data  Configure Block in jobDSL to handle not direct supported plugins 15 08/12/15
  • 16. Reference  jobDSL slides  http://www.slideshare.net/daspilker/configuration-as-code-the-job-dsl-plugin  JobDSL ref  https://github.com/jenkinsci/job-dsl-plugin/wiki/View-Reference  https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference  https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block  Groovy Json  http://www.groovy-lang.org/json.html  Exercise Gist  https://gist.github.com/larrycai/aeb9a3b037dcb17df9b2 16 08/12/15
  • 17. CodingWithMe  "CodingWithMe - Learning by Coding" is a coding workshop, it aims to learn one technology in 90 minutes by practice  Features:  4-5 well tuned hands on exercises in 90 minutes  First exercise shall be started in 20 minutes  It well follows Bob Pike’s 90/20/8 rules (happen to know)  It is recommended arranged for several parallel sessions if it is organized in the company. 17 08/12/15 http://www.larrycaiyu.com/blog/2014/03/18/codingwithme_introduction/