From 9957995e56387ed2b827b6d591b81c6d3efab74e Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 18 Sep 2018 09:36:49 -0400 Subject: [PATCH] ci-change: timeout in post-build-status (#1494) * Add timeout to `post-build-status-update` * Switch from shelling out `curl` to `httpRequest` PR-URL: https://github.com/nodejs/build/pull/1494 Reviewed-By: Matheus Marchini --- .../post-build-status-update.jenkinsfile | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/jenkins/pipelines/post-build-status-update.jenkinsfile b/jenkins/pipelines/post-build-status-update.jenkinsfile index 8a5c42767..aa02f93ee 100644 --- a/jenkins/pipelines/post-build-status-update.jenkinsfile +++ b/jenkins/pipelines/post-build-status-update.jenkinsfile @@ -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) + } } } } @@ -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) {