SlideShare una empresa de Scribd logo
1 de 17
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/

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Володимир Дубенко "Node.js for desktop development (based on Electron library)"Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
 
Testing with Docker
Testing with DockerTesting with Docker
Testing with Docker
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache GroovyBuilding an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache Groovy
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
 
JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsContinuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and Jenkins
 
Jenkins 101: Getting Started
Jenkins 101: Getting StartedJenkins 101: Getting Started
Jenkins 101: Getting Started
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
JavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as codeJavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as code
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationIBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2
 

Destacado

Intégration continue
Intégration continueIntégration continue
Intégration continue
Klee Group
 
綻放的
綻放的綻放的
綻放的
unotour
 

Destacado (20)

Configuration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginConfiguration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL Plugin
 
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at NetflixConfiguration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
 
8 lessons learned from becoming agile
8 lessons learned from becoming agile8 lessons learned from becoming agile
8 lessons learned from becoming agile
 
OpenStack Introduction Ecosystem
OpenStack Introduction EcosystemOpenStack Introduction Ecosystem
OpenStack Introduction Ecosystem
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
 
Jenkins Best Practices Meetup Slides
Jenkins Best Practices Meetup SlidesJenkins Best Practices Meetup Slides
Jenkins Best Practices Meetup Slides
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
 
Group Development
Group DevelopmentGroup Development
Group Development
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
So, you want to be a plugin developer?
So, you want to be a plugin developer?So, you want to be a plugin developer?
So, you want to be a plugin developer?
 
Intégration continue
Intégration continueIntégration continue
Intégration continue
 
Introduction to ci with jenkins
Introduction to ci with jenkinsIntroduction to ci with jenkins
Introduction to ci with jenkins
 
Lcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINXLcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINX
 
Introduction to OpenStack : Barcamp Bangkhen 2016
Introduction to OpenStack : Barcamp Bangkhen 2016Introduction to OpenStack : Barcamp Bangkhen 2016
Introduction to OpenStack : Barcamp Bangkhen 2016
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Job DSL Plugin for Jenkins
Job DSL Plugin for JenkinsJob DSL Plugin for Jenkins
Job DSL Plugin for Jenkins
 
Askep kelompok cempaka
Askep kelompok cempakaAskep kelompok cempaka
Askep kelompok cempaka
 
The top 5 things planners need to know about self-driving vehicles
The top 5 things planners need to know about self-driving vehiclesThe top 5 things planners need to know about self-driving vehicles
The top 5 things planners need to know about self-driving vehicles
 
Dr Chris Stout Getting Better at Private Practice
Dr Chris Stout Getting Better at Private PracticeDr Chris Stout Getting Better at Private Practice
Dr Chris Stout Getting Better at Private Practice
 
綻放的
綻放的綻放的
綻放的
 

Similar a Learn jobDSL for Jenkins

Similar a Learn jobDSL for Jenkins (20)

CICD Pipeline configuration as a code
CICD Pipeline configuration as a codeCICD Pipeline configuration as a code
CICD Pipeline configuration as a code
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 
Jenkins Job DSL plugin
Jenkins Job DSL plugin Jenkins Job DSL plugin
Jenkins Job DSL plugin
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
The power of dots
The power of dotsThe power of dots
The power of dots
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Oracle WebLogic: Feature Timeline from WLS9 to WLS 12c
Oracle WebLogic: Feature Timeline from WLS9 to WLS 12cOracle WebLogic: Feature Timeline from WLS9 to WLS 12c
Oracle WebLogic: Feature Timeline from WLS9 to WLS 12c
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS Meetup
 
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development team
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development teamMoving from CruiseControl.NET to Jenkins in the PVS-Studio development team
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development team
 
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development team
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development teamMoving from CruiseControl.NET to Jenkins in the PVS-Studio development team
Moving from CruiseControl.NET to Jenkins in the PVS-Studio development team
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
Continuous delivery the french way Agile Cambridge 2014
Continuous delivery the french way Agile Cambridge 2014Continuous delivery the french way Agile Cambridge 2014
Continuous delivery the french way Agile Cambridge 2014
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
fast_bitcoin_data_mining
fast_bitcoin_data_miningfast_bitcoin_data_mining
fast_bitcoin_data_mining
 
Let me introduce you: DOTS
Let me introduce you: DOTSLet me introduce you: DOTS
Let me introduce you: DOTS
 
Illia shestakov - The Future of Java JDK #9
Illia shestakov - The Future of Java JDK #9Illia shestakov - The Future of Java JDK #9
Illia shestakov - The Future of Java JDK #9
 
Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...
 

Más de Larry Cai

Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
Larry Cai
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
Larry Cai
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
Larry Cai
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
Larry Cai
 

Más de Larry Cai (17)

Learn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutes
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in docker
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software development
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration Introduction
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM tools
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

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/