CODE YOUR JENKINS JOBS WITH JOB DSL

January 20, 2017
Contact Us
Weekly Shorts are topics we discuss in our weekly remote meeting related to recent work we have done with our customers
CODE YOUR JENKINS JOBS WITH JOB DSL

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397779\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins04\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins04-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins04-LC1\" class=\"blob-code blob-code-inner js-file-line\">job(‘tmpl_base’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins04-LC2\" class=\"blob-code blob-code-inner js-file-line\"> disabled true<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins04-LC3\" class=\"blob-code blob-code-inner js-file-line\"> logRotator –1, 10, –1, –1<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins04-LC4\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins04-LC5\" class=\"blob-code blob-code-inner js-file-line\">job(‘real_job’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins04-LC6\" class=\"blob-code blob-code-inner js-file-line\"> using ‘tmpl_base’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins04-LC7\" class=\"blob-code blob-code-inner js-file-line\"> disabled false<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins04-LC8\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins04-LC9\" class=\"blob-code blob-code-inner js-file-line\"> shell ‘echo Rotates just like the template!’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins04-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins04-LC11\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/759cf25431ee1ad96b76105e72a2c09b/raw/f4016e67b51e6a5426ef0daea6c016f360429686/Jenkins04\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/759cf25431ee1ad96b76105e72a2c09b#file-jenkins04\">Jenkins04<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

Jenkins is a powerful automation platform to run your tests on a non-development machine whenever someone pushes new code into the source repository. It makes life easier. Almost immediate feedback tells you what and who introduced the problem, and you can fix it accordingly. Quite simply, Jenkins makes life easier.

But when it comes to operating Jenkins on the system’s user interface, you have to do it manually. Creating a new item, adding parameters, adding steps, choosing the job subject — you do all these by clicking buttons on the Jenkins UI. When the number of jobs grows, it becomes inconvenient to maintain them using the UI. For instance, if you want to add a general plug-in like Slack to all of your jobs, you will have to modify each job in your project and add the new plug-in, one by one.

If Jenkins crashes or if a user changes, updates, deletes or moves a job, it won’t be easy to reverse the changes. Jenkins saves all the jobs and their settings in XML files. In order to recover jobs, you have to copy and paste those files into the system — a very old-fashioned way to restore things, especially since the establishment of development version control tools. You might also lose data if you defined your hard disk back-up to save things once every day or two.

A cool Jenkins plugin called Job DSL can solve this problem by giving you the opportunity to program your jobs’ building process instead of clicking buttons on the UI. It also enables integration with version control tools like Git, so when a change is made, it will be preserved automatically. It’s pretty easy to restore an older version of your jobs. Using a base template for jobs can save time re-configuring settings, and it helps prevent inaccuracies and conflicts.

So how does it work? First, install or upgrade the Job DSL plugin for the Jenkins version you are using. You can do this as follows:

Jenkins > Manage Jenkins > Manage Plugins > Job DSL

Then, to create a new job for a build, you will have to make the following selection:

Jenkins > New Item > Add Build Step > Process Job DSLs

The template of adding additional job to DSL script , written in Groovy, looks like this:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397726\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins01\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins01-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins01-LC1\" class=\"blob-code blob-code-inner js-file-line\">def project = 'quidryan/aws-sdk-test'<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins01-LC2\" class=\"blob-code blob-code-inner js-file-line\">def branchApi = new URL("https://api.github.com/repos/${project}/branches")<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins01-LC3\" class=\"blob-code blob-code-inner js-file-line\">def branches = new groovy.json.JsonSlurper().parse(branchApi.newReader())<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins01-LC4\" class=\"blob-code blob-code-inner js-file-line\">branches.each {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins01-LC5\" class=\"blob-code blob-code-inner js-file-line\"> def branchName = it.name<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins01-LC6\" class=\"blob-code blob-code-inner js-file-line\"> def jobName = "${project}-${branchName}".replaceAll('/','-')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins01-LC7\" class=\"blob-code blob-code-inner js-file-line\"> job(jobName) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins01-LC8\" class=\"blob-code blob-code-inner js-file-line\"> scm {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins01-LC9\" class=\"blob-code blob-code-inner js-file-line\"> git("git://github.com/${project}.git", branchName)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins01-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins01-LC11\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L12\" class=\"blob-num js-line-number\" data-line-number=\"12\"><\/td>\n <td id=\"file-jenkins01-LC12\" class=\"blob-code blob-code-inner js-file-line\"> maven("test -Dproject.name=${project}/${branchName}")<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L13\" class=\"blob-num js-line-number\" data-line-number=\"13\"><\/td>\n <td id=\"file-jenkins01-LC13\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L14\" class=\"blob-num js-line-number\" data-line-number=\"14\"><\/td>\n <td id=\"file-jenkins01-LC14\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins01-L15\" class=\"blob-num js-line-number\" data-line-number=\"15\"><\/td>\n <td id=\"file-jenkins01-LC15\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/422299fde8fe8eabc4ed1660097a2cd2/raw/69afc6a15acc72776dd2969d9b98982b54542029/Jenkins01\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/422299fde8fe8eabc4ed1660097a2cd2#file-jenkins01\">Jenkins01<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

All methods that will be needed to write the code according to your requirements — like buildFlowJob(String name), buildMonitorView(String name), buildPipelineView(String name) and more — can be found here.

If you are looking to set up multiple jobs so you can create a full hierarchy of Jenkins jobs that will be executed in sequence or in parallel, you can import the code from here.

The template looks like this:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397730\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins02\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins02-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins02-LC1\" class=\"blob-code blob-code-inner js-file-line\">multiJob('example') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins02-LC2\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins02-LC3\" class=\"blob-code blob-code-inner js-file-line\"> phase('Second') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins02-LC4\" class=\"blob-code blob-code-inner js-file-line\"> phaseJob('JobZ') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins02-LC5\" class=\"blob-code blob-code-inner js-file-line\"> parameters {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins02-LC6\" class=\"blob-code blob-code-inner js-file-line\"> propertiesFile('my1.properties')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins02-LC7\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins02-LC8\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins02-LC9\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins02-LC10\" class=\"blob-code blob-code-inner js-file-line\"> phase('Third') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins02-LC11\" class=\"blob-code blob-code-inner js-file-line\"> phaseJob('JobA')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L12\" class=\"blob-num js-line-number\" data-line-number=\"12\"><\/td>\n <td id=\"file-jenkins02-LC12\" class=\"blob-code blob-code-inner js-file-line\"> phaseJob('JobB')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L13\" class=\"blob-num js-line-number\" data-line-number=\"13\"><\/td>\n <td id=\"file-jenkins02-LC13\" class=\"blob-code blob-code-inner js-file-line\"> phaseJob('JobC')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L14\" class=\"blob-num js-line-number\" data-line-number=\"14\"><\/td>\n <td id=\"file-jenkins02-LC14\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L15\" class=\"blob-num js-line-number\" data-line-number=\"15\"><\/td>\n <td id=\"file-jenkins02-LC15\" class=\"blob-code blob-code-inner js-file-line\"> phase('Fourth') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L16\" class=\"blob-num js-line-number\" data-line-number=\"16\"><\/td>\n <td id=\"file-jenkins02-LC16\" class=\"blob-code blob-code-inner js-file-line\"> phaseJob('JobD') {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L17\" class=\"blob-num js-line-number\" data-line-number=\"17\"><\/td>\n <td id=\"file-jenkins02-LC17\" class=\"blob-code blob-code-inner js-file-line\"> currentJobParameters(false)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L18\" class=\"blob-num js-line-number\" data-line-number=\"18\"><\/td>\n <td id=\"file-jenkins02-LC18\" class=\"blob-code blob-code-inner js-file-line\"> parameters {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L19\" class=\"blob-num js-line-number\" data-line-number=\"19\"><\/td>\n <td id=\"file-jenkins02-LC19\" class=\"blob-code blob-code-inner js-file-line\"> booleanParam('cParam', true)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L20\" class=\"blob-num js-line-number\" data-line-number=\"20\"><\/td>\n <td id=\"file-jenkins02-LC20\" class=\"blob-code blob-code-inner js-file-line\"> propertiesFile('my.properties')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L21\" class=\"blob-num js-line-number\" data-line-number=\"21\"><\/td>\n <td id=\"file-jenkins02-LC21\" class=\"blob-code blob-code-inner js-file-line\"> sameNode()<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L22\" class=\"blob-num js-line-number\" data-line-number=\"22\"><\/td>\n <td id=\"file-jenkins02-LC22\" class=\"blob-code blob-code-inner js-file-line\"> matrixSubset('it.name=="hello"')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L23\" class=\"blob-num js-line-number\" data-line-number=\"23\"><\/td>\n <td id=\"file-jenkins02-LC23\" class=\"blob-code blob-code-inner js-file-line\"> subversionRevision()<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L24\" class=\"blob-num js-line-number\" data-line-number=\"24\"><\/td>\n <td id=\"file-jenkins02-LC24\" class=\"blob-code blob-code-inner js-file-line\"> gitRevision()<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L25\" class=\"blob-num js-line-number\" data-line-number=\"25\"><\/td>\n <td id=\"file-jenkins02-LC25\" class=\"blob-code blob-code-inner js-file-line\"> predefinedProp('prop1', 'value1')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L26\" class=\"blob-num js-line-number\" data-line-number=\"26\"><\/td>\n <td id=\"file-jenkins02-LC26\" class=\"blob-code blob-code-inner js-file-line\"> nodeLabel('lParam', 'my_nodes')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L27\" class=\"blob-num js-line-number\" data-line-number=\"27\"><\/td>\n <td id=\"file-jenkins02-LC27\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L28\" class=\"blob-num js-line-number\" data-line-number=\"28\"><\/td>\n <td id=\"file-jenkins02-LC28\" class=\"blob-code blob-code-inner js-file-line\"> configure { phaseJobConfig -><\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L29\" class=\"blob-num js-line-number\" data-line-number=\"29\"><\/td>\n <td id=\"file-jenkins02-LC29\" class=\"blob-code blob-code-inner js-file-line\"> phaseJobConfig / enableCondition << 'true'<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L30\" class=\"blob-num js-line-number\" data-line-number=\"30\"><\/td>\n <td id=\"file-jenkins02-LC30\" class=\"blob-code blob-code-inner js-file-line\"> phaseJobConfig / condition << '${RUN_JOB} == "true"'<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L31\" class=\"blob-num js-line-number\" data-line-number=\"31\"><\/td>\n <td id=\"file-jenkins02-LC31\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L32\" class=\"blob-num js-line-number\" data-line-number=\"32\"><\/td>\n <td id=\"file-jenkins02-LC32\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L33\" class=\"blob-num js-line-number\" data-line-number=\"33\"><\/td>\n <td id=\"file-jenkins02-LC33\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L34\" class=\"blob-num js-line-number\" data-line-number=\"34\"><\/td>\n <td id=\"file-jenkins02-LC34\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins02-L35\" class=\"blob-num js-line-number\" data-line-number=\"35\"><\/td>\n <td id=\"file-jenkins02-LC35\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/247c7dbbe289e99b3cbc5ca491626ff0/raw/ae87b7005e05504c9597b71bba956f465bca22e0/Jenkins02\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/247c7dbbe289e99b3cbc5ca491626ff0#file-jenkins02\">Jenkins02<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

The jobs in each “phase” will be executed in parallel, and the phases are sequential, meaning the jobs in phase 2 will be executed only after the phase 1 jobs are completed.

The Job DSL plugin for Jenkins allows you to create and update job configurations in Jenkins based on source code written in the Groovy language. The basic job declaration structure looks like this:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397763\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins03\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins03-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins03-LC1\" class=\"blob-code blob-code-inner js-file-line\">job(‘example’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins03-LC2\" class=\"blob-code blob-code-inner js-file-line\"> scm {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins03-LC3\" class=\"blob-code blob-code-inner js-file-line\"> git ‘git@om-git.mm.local/project/name.git’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins03-LC4\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins03-LC5\" class=\"blob-code blob-code-inner js-file-line\"> triggers {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins03-LC6\" class=\"blob-code blob-code-inner js-file-line\"> scm ‘*/15 * * * *’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins03-LC7\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins03-LC8\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins03-LC9\" class=\"blob-code blob-code-inner js-file-line\"> bt()<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins03-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins03-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins03-LC11\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/fa78dc4f9a268ecf9588758814c7f5a7/raw/2c46d44d244fb485c165597b9b146113ef6e1537/Jenkins03\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/fa78dc4f9a268ecf9588758814c7f5a7#file-jenkins03\">Jenkins03<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

There are several ways to reuse code when using the Jenkins Job DSL plug-in:

1. Use a template that declares a job, and multiple jobs can inherit this template. Every change to the template job will also propagate to other jobs that use it. Example:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397779\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins04\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins04-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins04-LC1\" class=\"blob-code blob-code-inner js-file-line\">job(‘tmpl_base’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins04-LC2\" class=\"blob-code blob-code-inner js-file-line\"> disabled true<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins04-LC3\" class=\"blob-code blob-code-inner js-file-line\"> logRotator –1, 10, –1, –1<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins04-LC4\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins04-LC5\" class=\"blob-code blob-code-inner js-file-line\">job(‘real_job’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins04-LC6\" class=\"blob-code blob-code-inner js-file-line\"> using ‘tmpl_base’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins04-LC7\" class=\"blob-code blob-code-inner js-file-line\"> disabled false<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins04-LC8\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins04-LC9\" class=\"blob-code blob-code-inner js-file-line\"> shell ‘echo Rotates just like the template!’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins04-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins04-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins04-LC11\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/759cf25431ee1ad96b76105e72a2c09b/raw/f4016e67b51e6a5426ef0daea6c016f360429686/Jenkins04\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/759cf25431ee1ad96b76105e72a2c09b#file-jenkins04\">Jenkins04<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

2. Use the Groovy language to create more than one job using a loop or some other iteration. Example:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397799\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins05\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins05-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins05-LC1\" class=\"blob-code blob-code-inner js-file-line\">[ “first_prj”, “second_prj” ].each { project_name -><\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins05-LC2\" class=\"blob-code blob-code-inner js-file-line\">GitLabJsonApiBranchesFor(project_name).each { branch -><\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins05-LC3\" class=\"blob-code blob-code-inner js-file-line\"> job (“${project_name}-${branch}”) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins05-LC4\" class=\"blob-code blob-code-inner js-file-line\"> scm {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins05-LC5\" class=\"blob-code blob-code-inner js-file-line\"> git “git@om-git.mm.local:${project_name}”<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins05-LC6\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins05-LC7\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins05-LC8\" class=\"blob-code blob-code-inner js-file-line\"> shell ‘scripts/build.sh’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins05-LC9\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins05-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins05-LC11\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins05-L12\" class=\"blob-num js-line-number\" data-line-number=\"12\"><\/td>\n <td id=\"file-jenkins05-LC12\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/c025b747c5ed0c250e8254a1d73dd08b/raw/334b0f4fc3c69473d699e569e4731528e43289c4/Jenkins05\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/c025b747c5ed0c250e8254a1d73dd08b#file-jenkins05\">Jenkins05<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

3. Extend the DSL language using a library of helpers that can be reused in multiple jobs. Example:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397832\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins06\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins06-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins06-LC1\" class=\"blob-code blob-code-inner js-file-line\">// Filename: common.groovy<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins06-LC2\" class=\"blob-code blob-code-inner js-file-line\">class common {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins06-LC3\" class=\"blob-code blob-code-inner js-file-line\"> static {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins06-LC4\" class=\"blob-code blob-code-inner js-file-line\"> ScmContext.metaClass {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins06-LC5\" class=\"blob-code blob-code-inner js-file-line\"> agtGit { String url, Closure configure = null -><\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins06-LC6\" class=\"blob-code blob-code-inner js-file-line\"> git {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins06-LC7\" class=\"blob-code blob-code-inner js-file-line\"> delegate.remote {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins06-LC8\" class=\"blob-code blob-code-inner js-file-line\"> delegate.url(url)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins06-LC9\" class=\"blob-code blob-code-inner js-file-line\"> delegate.credentials(‘jenkins’)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-jenkins06-LC10\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-jenkins06-LC11\" class=\"blob-code blob-code-inner js-file-line\"> delegate.branch ‘develop’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L12\" class=\"blob-num js-line-number\" data-line-number=\"12\"><\/td>\n <td id=\"file-jenkins06-LC12\" class=\"blob-code blob-code-inner js-file-line\"> delegate.configure(configure)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L13\" class=\"blob-num js-line-number\" data-line-number=\"13\"><\/td>\n <td id=\"file-jenkins06-LC13\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L14\" class=\"blob-num js-line-number\" data-line-number=\"14\"><\/td>\n <td id=\"file-jenkins06-LC14\" class=\"blob-code blob-code-inner js-file-line\"> } <\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L15\" class=\"blob-num js-line-number\" data-line-number=\"15\"><\/td>\n <td id=\"file-jenkins06-LC15\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L16\" class=\"blob-num js-line-number\" data-line-number=\"16\"><\/td>\n <td id=\"file-jenkins06-LC16\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L17\" class=\"blob-num js-line-number\" data-line-number=\"17\"><\/td>\n <td id=\"file-jenkins06-LC17\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins06-L18\" class=\"blob-num js-line-number\" data-line-number=\"18\"><\/td>\n <td id=\"file-jenkins06-LC18\" class=\"blob-code blob-code-inner js-file-line\">// Filename: real_job.groovy<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/9931dfe5501c0ec246e6a1dd2c48e9b7/raw/2594b7875bad014970c650d80def607d032683ac/Jenkins06\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/9931dfe5501c0ec246e6a1dd2c48e9b7#file-jenkins06\">Jenkins06<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

import common # common.groovy must be in the same folder as this file

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397841\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins07\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins07-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins07-LC1\" class=\"blob-code blob-code-inner js-file-line\">use(common) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins07-LC2\" class=\"blob-code blob-code-inner js-file-line\"> job(‘example’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins07-LC3\" class=\"blob-code blob-code-inner js-file-line\"> scm {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins07-LC4\" class=\"blob-code blob-code-inner js-file-line\"> // use the custom ScmContex agtGit helper<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins07-LC5\" class=\"blob-code blob-code-inner js-file-line\"> agtGit(‘git@om-git.mm.local:someproject.git’)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins07-LC6\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins07-LC7\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins07-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins07-LC8\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/609152d56c00722ed0a3b46413aac108/raw/48ed3c06ba369dfe7f81a34f807755fc24453f25/Jenkins07\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/609152d56c00722ed0a3b46413aac108#file-jenkins07\">Jenkins07<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

4. The Jenkins Job DSL supports most of the plugins available to Jenkins, but from time to time Job DSL needs to generate XML lines for config.xml that are not supported out of the box. For this purpose, most DSL helpers (and the main project helper) have a configure block that can generate XML directly.

Example:

#gist:<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-87673c31a5b37b5e6556b63e1081ebbc.css"><div id=\"gist90397856\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-jenkins08\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-text\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-jenkins08-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-jenkins08-LC1\" class=\"blob-code blob-code-inner js-file-line\">job(‘example_sonar_job’) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-jenkins08-LC2\" class=\"blob-code blob-code-inner js-file-line\"> steps {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-jenkins08-LC3\" class=\"blob-code blob-code-inner js-file-line\"> sbt()<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-jenkins08-LC4\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-jenkins08-LC5\" class=\"blob-code blob-code-inner js-file-line\">// force order (sonar runs second) in config.xml<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-jenkins08-LC6\" class=\"blob-code blob-code-inner js-file-line\"> configure {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-jenkins08-LC7\" class=\"blob-code blob-code-inner js-file-line\"> it / ‘builders’ / ‘hudson.plugins.sonar.SonarRunnerBuilder’<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-jenkins08-LC8\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-jenkins08-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-jenkins08-LC9\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/seanroisentul/11c4cab5f9ed934568637e60f84699ae/raw/56ab17bc469a4d58b9742f6f6485cffae72d9ed4/Jenkins08\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/seanroisentul/11c4cab5f9ed934568637e60f84699ae#file-jenkins08\">Jenkins08<\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n

CODE YOUR JENKINS JOBS WITH JOB DSL
Daniela Kortin Shterenzon
Operation & Community Manager
Daniela runs the finance and operations at ProdOps; from making sure the company has smooth operations and logistics activities as less as possible to running marketing campaigns and organizing meetups and public events. You can trust her common sense in any decision she needs to make. Her strength in finding ways to minimize waste. She must have been an octopus in a previous life due to the many things she has to handle at once!