Created
January 5, 2017 08:00
-
-
Save razbomi/f467872d4105cb987d69751ba3e4e132 to your computer and use it in GitHub Desktop.
Jenkinsfile pipeline closure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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