Skip to content

Instantly share code, notes, and snippets.

@sboardwell
Created August 7, 2019 21:51
Show Gist options
  • Save sboardwell/16a2f66a5a138e1389dc17d2e9da5d17 to your computer and use it in GitHub Desktop.
Save sboardwell/16a2f66a5a138e1389dc17d2e9da5d17 to your computer and use it in GitHub Desktop.
pipeline {
options { ... }
parameters { ... }
agent { ... }
stages {
stage('Test') {
when {
changeRequest()
}
steps {
sh 'gradle clean test'
}
post {
always {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/build/reports/tests/**/*.*'
junit allowEmptyResults: true, testResults: '**/build/test-results/test/*.xml'
}
}
}
stage('Run DSL') {
when {
anyOf {
branch 'master'
}
}
steps {
script {
try {
jobDsl(
failOnMissingPlugin: true,
removedConfigFilesAction: 'DELETE',
removedJobAction: 'DELETE',
removedViewAction: 'DELETE',
targets: 'jobs/**/*.groovy',
unstableOnDeprecation: true
)
} catch (def e) {
timeout(50) {
echo "Looks like we might have to approve some DSL scripts. Please check at ${JENKINS_URL}/scriptApproval"
input "DSL Scripts approved? Then 'continue', otherwise 'abort'."
jobDsl(
failOnMissingPlugin: true,
removedConfigFilesAction: 'DELETE',
removedJobAction: 'DELETE',
removedViewAction: 'DELETE',
targets: 'jobs/**/*.groovy',
unstableOnDeprecation: true
)
}
}
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment