-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jenkins: post-build-status-update #973
Changes from 5 commits
dd8290e
ac5f261
a2059de
c5cad36
55a5ebe
d61eb49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env groovy | ||
|
||
// DESCRIPTION: | ||
// Sends the status of a node-test-commit-* sub build to the Github Bot, which | ||
// then updates the corresponding PR's CI status on github.com. | ||
|
||
import groovy.json.JsonOutput | ||
|
||
pipeline { | ||
agent { label 'jenkins-workspace' } | ||
|
||
parameters { | ||
string(defaultValue: '', description: 'test/aix, linter, etc.', name: 'IDENTIFIER') | ||
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
Sorry, something went wrong. |
||
string(defaultValue: '', description: 'pending, success, unstable, failure', name: 'STATUS') | ||
string(defaultValue: '', description: 'URL for upstream Jenkins job', name: 'URL') | ||
string(defaultValue: '', description: 'Current commit being tested in upstream Jenkins job', name: 'COMMIT') | ||
string(defaultValue: '', description: 'Current branch being tested in upstream Jenkins job', name: 'REF') | ||
} | ||
|
||
stages { | ||
stage('Send status report') { | ||
steps { | ||
validateParams(params) | ||
sendBuildStatus(params.IDENTIFIER, params.STATUS, params.URL, params.COMMIT, params.REF) | ||
} | ||
} | ||
} | ||
} | ||
|
||
def sendBuildStatus(identifier, status, url, commit, ref) { | ||
def path = "" | ||
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
Sorry, something went wrong. |
||
def message = "" | ||
|
||
if (status == "pending") { | ||
path = "start" | ||
message = "running tests" | ||
} else if (status == "failure") { | ||
path = "end" | ||
message = "tests failed" | ||
} else if (status == "unstable") { | ||
path = "end" | ||
message = "flaky tests failed" | ||
status = "success" | ||
} else if (status == "success") { | ||
path = "end" | ||
message = "tests passed" | ||
} | ||
|
||
def buildPayload = JsonOutput.toJson([ | ||
'identifier': identifier, | ||
'status': status, | ||
'url': url, | ||
'commit': commit, | ||
'ref': ref, | ||
'message': message | ||
]) | ||
|
||
def script = "curl -s -o /dev/null --connect-timeout 5 -X POST " + | ||
"-H 'Content-Type: application/json' -d '${buildPayload}' " + | ||
"http://github-bot.nodejs.org:3333/node/jenkins/${path}" | ||
|
||
sh(returnStdout: true, script: script) | ||
} | ||
|
||
def validateParams(params) { | ||
if (params.IDENTIFIER == '' || params.STATUS == '' || params.URL == '' || | ||
params.COMMIT == '' || params.REF == '') { | ||
error('All parameter fields are required.') | ||
} | ||
} |
This comment was marked as off-topic.
Sorry, something went wrong.