Created
August 28, 2018 12:11
-
-
Save pavlospt/48fddca46c8d5630b6d33f2601dd93fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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