Skip to content

Instantly share code, notes, and snippets.

@razbomi
Created January 5, 2017 08:00
Show Gist options
  • Save razbomi/f467872d4105cb987d69751ba3e4e132 to your computer and use it in GitHub Desktop.
Save razbomi/f467872d4105cb987d69751ba3e4e132 to your computer and use it in GitHub Desktop.
Jenkinsfile pipeline closure
pimpMyStage('build') { stage ->
echo "Body of stage ${stage}"
}
def pimpMyStage(name,Closure body) {
node(name) {
stage name
timestamps {
colours {
keys {
sh "printf \"\\e[31mStage ${name}\\e[0m\\n\""
body(name)
}
}
}
}
}
def colours(Closure body) {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
body()
}
}
def keys(Closure body) {
sshagent([env.JENKINS_GIT_USER]) {
body()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment