Skip to content

Commit

Permalink
pipeline: check inputs in post-build-status-update
Browse files Browse the repository at this point in the history
Make sure PR is a number, and the `POST_STATUS_TO_PR` is set.

Refs: nodejs#973 (comment)
  • Loading branch information
gibfahn committed Nov 6, 2017
1 parent d28795d commit 5fe3982
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jenkins/pipelines/post-build-status-update.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ pipeline {
}

def sendBuildStatus(repo, identifier, status, url, commit, ref) {

// Fail quietly if upstream job shouldn't be posting to GitHub.
if (!PR.isInteger() || POST_STATUS_TO_PR != 'true') {
println "Skipping status update (PR.isInteger(): ${PR.isInteger}, " +
"POST_STATUS_TO_PR: ${POST_STATUS_TO_PR}."
return
}

def path = ""
def message = ""

Expand Down Expand Up @@ -64,6 +72,7 @@ def sendBuildStatus(repo, identifier, status, url, commit, ref) {
}

def validateParams(params) {
// Fail loudly if upstream job is configured wrong.
if (params.IDENTIFIER == '' || params.STATUS == '' || params.URL == '' ||
params.COMMIT == '' || params.REF == '') {
error('All parameter fields are required.')
Expand Down

0 comments on commit 5fe3982

Please sign in to comment.