Skip to content

Instantly share code, notes, and snippets.

@zagy
Last active November 14, 2018 13:04
Show Gist options
  • Save zagy/5345d730c70005e3c75fad4090998fee to your computer and use it in GitHub Desktop.
Save zagy/5345d730c70005e3c75fad4090998fee to your computer and use it in GitHub Desktop.
// copied from http://www.aimtheory.com/jenkins/pipeline/continuous-delivery/2017/12/02/jenkins-pipeline-global-shared-library-best-practices.html
// /src/org/acme/pythonPipeline.groovy
#!/usr/bin/groovy
package org.acme;
pythonPipeline(pipelineDefinition) {
// Create a globally accessible variable that makes
// the YAML pipeline definition available to all scripts
pd = pipelineDefinition
}
def executePipeline() {
node {
if (runTests) {
stage('Run Tests') {
sh pd.testCommand
}
}
if (deployUponTestSuccess) {
stage('Deploy') {
sh "path/to/a/deploy/bash/script.sh ${pd.deploymentEnvironment}"
}
}
}
}
return this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment