summaryrefslogtreecommitdiff
path: root/Jenkinsfile
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-15 12:06:35 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-15 12:29:16 +0200
commitc8302cd6fcac53ce7d20e8fbfe9db5d3dc3a2cd3 (patch)
tree22394daf54fb44c3da70f6b12b1b369853378bcb /Jenkinsfile
parent38f06da2873119310e1c83beb90dd3958c99a517 (diff)
downloadvyos-build-c8302cd6fcac53ce7d20e8fbfe9db5d3dc3a2cd3.tar.gz
vyos-build-c8302cd6fcac53ce7d20e8fbfe9db5d3dc3a2cd3.zip
Jenkins: fix GitHub JSON API interface
Diffstat (limited to 'Jenkinsfile')
-rw-r--r--Jenkinsfile23
1 files changed, 12 insertions, 11 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index c4993982..68e0e724 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -56,20 +56,21 @@ def setDescription() {
item.save()
}
-def setGitHubStatus(message) {
+def setGitHubStatus(state, description) {
if (isCustomBuild())
return
withCredentials([string(credentialsId: 'GitHub-API-Token', variable: 'TOKEN')]) {
- sh "env"
- sh """
- curl -XPOST -H "Authorization: token ${TOKEN}" https://api.github.com/repos/vyos/vyos-build/statuses/\$(git rev-parse HEAD) -d "{
- \"state\": \"pending\",
- \"target_url\": \"${BUILD_URL}\",
- \"description\": \"${message}\",
- \"context\": \"continuous-integration/jenkins\"
- }"
- """
+ def commitId = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
+ def postBody = [
+ state: "${state}",
+ target_url: "${BUILD_URL}",
+ description: "${description}",
+ context: 'continuous-integration/jenkins',
+ ]
+ def postBodyString = groovy.json.JsonOutput.toJson(postBody)
+ sh "curl 'https://api.github.com/repos/vyos/vyos-build/statuses/${commitId}?access_token=${TOKEN}' \
+ -H 'Content-Type: application/json' -X POST -d '${postBodyString}' -k"
}
}
@@ -102,7 +103,7 @@ pipeline {
stage('Configure') {
steps {
script {
- setGitHubStatus("Build is pending!")
+ setGitHubStatus("pending", "Build pending")
sh """
./configure --build-by="autobuild@vyos.net" --debian-mirror="http://ftp.us.debian.org/debian/"
"""