Skip to content

Commit 9957995

Browse files
authored
ci-change: timeout in post-build-status (#1494)
* Add timeout to `post-build-status-update` * Switch from shelling out `curl` to `httpRequest` PR-URL: #1494 Reviewed-By: Matheus Marchini <matheus@sthima.com>
1 parent ed148a4 commit 9957995

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

jenkins/pipelines/post-build-status-update.jenkinsfile

+21-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pipeline {
2222
stage('Send status report') {
2323
steps {
2424
validateParams(params)
25-
sendBuildStatus(params.REPO, params.IDENTIFIER, params.STATUS, params.URL, params.COMMIT, params.REF)
25+
timeout(activity: true, time: 30, unit: 'SECONDS') {
26+
sendBuildStatus(params.REPO, params.IDENTIFIER, params.STATUS, params.URL, params.COMMIT, params.REF)
27+
}
2628
}
2729
}
2830
}
@@ -56,11 +58,24 @@ def sendBuildStatus(repo, identifier, status, url, commit, ref) {
5658
'message': message
5759
])
5860

59-
def script = "curl --ipv4 -s -o /dev/null --connect-timeout 5 -X POST " +
60-
"-H 'Content-Type: application/json' -d '${buildPayload}' " +
61-
"http://github-bot.nodejs.org:3333/${repo}/jenkins/${path}"
62-
63-
sh(returnStdout: true, script: script)
61+
println(buildPayload)
62+
63+
def response
64+
try {
65+
response = httpRequest(
66+
url: "http://github-bot.nodejs.org:3333/${repo}/jenkins/${path}",
67+
httpMode: "POST",
68+
timeout: 30,
69+
contentType: 'APPLICATION_JSON_UTF8',
70+
requestBody: buildPayload
71+
)
72+
} catch (Exception e) {
73+
println(e.toString())
74+
if (response) {
75+
println("Status: "+response.status)
76+
println("Content: "+response.content)
77+
}
78+
}
6479
}
6580

6681
def validateParams(params) {

0 commit comments

Comments
 (0)