Skip to content

Latest commit

 

History

History
 
 

02-job-dsl

jenkins-example-job-dsl

This example, based on the gradle-build example, uses the Job DSL Plugin to deploy the job configuration programmatically.

Instead of copying over the config.xml file for the managed job, the job is defined in a groovy script using the provided DSL.

Check out the blog article for this example.

How does it work?

  1. When the docker image is built, the seed job and the dsl script are copied over to Jenkins home.
  2. When running the docker image, the startup script builds the seed job.
  3. The seed job runs the DSL script, programmatically creating the job 'an-example-of-github-project'.

Files changed (comparing to gradle-build example)

.
├── jenkins-home
│   ├── init.groovy.d 
│   │   └── startup.groovy                  # run the seed job
│   ├── jobs
│   │   └── seed                            # seed job definition (should be the only config.xml)
│   ├── dsl
│   │   └── managedJobs.groovy.override     # dsl script to create the managed jobs
│   └── plugins.txt                         # job-dsl plugin was added
└── Dockerfile                              # copy over the dsl directory

Quick start

Video Tutorials

Video: Introduction to Jenkins DSL

Why using the DSL?

The Job DSL Plugin allows the programmatic creation of projects using a DSL. This method is preferred over managing the job config.xml file(s). The DSL is more compact and readable compared to the XML format. Since the DSL is executed as a groovy script, it allows runtime logic (docker run time) whereas the XML file is a static content (docker build time).

Dockerhub

Hosted at ticketfly/jenkins-example-job-dsl

Requirements

  • Docker Version 1.10 or higher.

Resources