Skip to content

Instantly share code, notes, and snippets.

@pavlospt
Created August 28, 2018 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavlospt/48fddca46c8d5630b6d33f2601dd93fa to your computer and use it in GitHub Desktop.
Save pavlospt/48fddca46c8d5630b6d33f2601dd93fa to your computer and use it in GitHub Desktop.
def postCommitStatus(params = [:]) {
withCredentials([
string([credentialsId: 'your-credentials-id', variable: 'GITHUB_API_TOKEN'])
]) {
def authHeaders = [[name: 'Authorization', value: "token ${GITHUB_API_TOKEN}"]]
def commit = params.commit
def requestBody = params.body
def statusUrl = "https://api.github.com/repos/repo-owner/repo-name/statuses/${commit}"
try {
def response = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: requestBody, url: statusUrl, customHeaders: authHeaders
} catch(e) {
throw e
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment