Skip to content

Commit

Permalink
ci-change: timeout in post-build-status (#1494)
Browse files Browse the repository at this point in the history
* Add timeout to `post-build-status-update`
* Switch from shelling out `curl` to `httpRequest`

PR-URL: #1494
Reviewed-By: Matheus Marchini <[email protected]>
  • Loading branch information
refack authored Sep 18, 2018
1 parent ed148a4 commit 9957995
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions jenkins/pipelines/post-build-status-update.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pipeline {
stage('Send status report') {
steps {
validateParams(params)
sendBuildStatus(params.REPO, params.IDENTIFIER, params.STATUS, params.URL, params.COMMIT, params.REF)
timeout(activity: true, time: 30, unit: 'SECONDS') {
sendBuildStatus(params.REPO, params.IDENTIFIER, params.STATUS, params.URL, params.COMMIT, params.REF)
}
}
}
}
Expand Down Expand Up @@ -56,11 +58,24 @@ def sendBuildStatus(repo, identifier, status, url, commit, ref) {
'message': message
])

def script = "curl --ipv4 -s -o /dev/null --connect-timeout 5 -X POST " +
"-H 'Content-Type: application/json' -d '${buildPayload}' " +
"http://github-bot.nodejs.org:3333/${repo}/jenkins/${path}"

sh(returnStdout: true, script: script)
println(buildPayload)

def response
try {
response = httpRequest(
url: "http://github-bot.nodejs.org:3333/${repo}/jenkins/${path}",
httpMode: "POST",
timeout: 30,
contentType: 'APPLICATION_JSON_UTF8',
requestBody: buildPayload
)
} catch (Exception e) {
println(e.toString())
if (response) {
println("Status: "+response.status)
println("Content: "+response.content)
}
}
}

def validateParams(params) {
Expand Down

0 comments on commit 9957995

Please sign in to comment.