Skip to content

Instantly share code, notes, and snippets.

@begeeben
Created March 5, 2019 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save begeeben/004e2febe1593ea644104a1e44b9419d to your computer and use it in GitHub Desktop.
Save begeeben/004e2febe1593ea644104a1e44b9419d to your computer and use it in GitHub Desktop.
Jenkins pipeline examples
// send build commit status to Github a pull request
def getCommitSha() {
dir('webfront_general') {
sh "git rev-parse HEAD > .git/current-commit"
return readFile(".git/current-commit").trim()
}
}
def setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/u-next/webfront_general.git"],
commitShaSource: [$class: "ManuallyEnteredShaSource", sha: getCommitSha()],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment