mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
Jenkins: fix GitHub JSON API interface
This commit is contained in:
parent
38f06da287
commit
c8302cd6fc
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -56,20 +56,21 @@ def setDescription() {
|
|||||||
item.save()
|
item.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
def setGitHubStatus(message) {
|
def setGitHubStatus(state, description) {
|
||||||
if (isCustomBuild())
|
if (isCustomBuild())
|
||||||
return
|
return
|
||||||
|
|
||||||
withCredentials([string(credentialsId: 'GitHub-API-Token', variable: 'TOKEN')]) {
|
withCredentials([string(credentialsId: 'GitHub-API-Token', variable: 'TOKEN')]) {
|
||||||
sh "env"
|
def commitId = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
||||||
sh """
|
def postBody = [
|
||||||
curl -XPOST -H "Authorization: token ${TOKEN}" https://api.github.com/repos/vyos/vyos-build/statuses/\$(git rev-parse HEAD) -d "{
|
state: "${state}",
|
||||||
\"state\": \"pending\",
|
target_url: "${BUILD_URL}",
|
||||||
\"target_url\": \"${BUILD_URL}\",
|
description: "${description}",
|
||||||
\"description\": \"${message}\",
|
context: 'continuous-integration/jenkins',
|
||||||
\"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') {
|
stage('Configure') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
setGitHubStatus("Build is pending!")
|
setGitHubStatus("pending", "Build pending")
|
||||||
sh """
|
sh """
|
||||||
./configure --build-by="autobuild@vyos.net" --debian-mirror="http://ftp.us.debian.org/debian/"
|
./configure --build-by="autobuild@vyos.net" --debian-mirror="http://ftp.us.debian.org/debian/"
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user