+gitUrl = 'git@scmhosting.org/org/project.git'
+folderName = 'jobdsl-example'
+defaultViewName = 'Pipeline View'
+initialJobName = "1-build"
+ primaryView(defaultViewName)
+deliveryPipelineView("${folderName}/${defaultViewName}") {
+ allowPipelineStart(true)
+ enableManualTriggers(true)
+ component("JobDSL pipeline view", initialJobName)
+job("${folderName}/template") {
+ // Configure job retention policy
+ logRotator(daysToKeep=14, numToKeep=10, artifactDaysToKeep=14, artifactNumToKeep=10)
+ colorizeOutput('xterm') // colours in job logs
+ timestamps() // timestamps in job logs
+ // Append shortened git hash to build name
+ // Bind environment variable to binary-repo credentials from Jenkins credentials store
+ buildName('#${BUILD_NUMBER}-${GIT_REVISION,length=7}')
+ usernamePassword(usernameVariable='BINARY_REPO_READ_USR', passwordVariable='BINARY_REPO_READ_PSW', credentialsId='binary-repo-read')
+ credentials('gitCredentials')
+ // Wiping out the workspace (to limit unnecessary surprises and backup size)
+ deleteDirectories(true)
+job("${folderName}/${initialJobName}") {
+ using "${folderName}/template"
+ // Sets up pipeline trigger using SCM change polling
+ archiveJunit('**/build/test-results/*.xml')
+ // Manual trigger for production release
+ buildPipelineTrigger("${folderName}/2-publish")
+job("${folderName}/2-publish") {
+// Only bind binary-repo-write credentials in publish stage
+ using "${folderName}/template"
+ usernamePassword(usernameVariable='BINARY_REPO_WRITE_USR', passwordVariable='BINARY_REPO_WRITE_PSW', credentialsId='binary-repo-write')
+ gradle('clean publish')