Created
February 23, 2020 22:52
-
-
Save naturalett/f55b7f56fa01618f034d21d013b818d1 to your computer and use it in GitHub Desktop.
buildGithubCheck
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 buildGithubCheck(repository, commitID, privateKey, status, checkName) { | |
def currentTime = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") | |
def checkName_run_id | |
jsonWebToken = getJsonWebToken(privateKey) | |
getStatusCode = validateAuth(jsonWebToken) | |
if (!(getStatusCode in [200,201])) { | |
error "Authentication request failed, status code: ${getStatusCode}" | |
} | |
token = getToken(jsonWebToken) | |
try { | |
checkName_run_id = getPreviousCheckNameRunID(repository, commitID, token, checkName) | |
} catch(Exception e) { | |
echo "Exception: ${e}" | |
echo "Check name does not exist" | |
} | |
if (checkName_run_id) { | |
getStatusCode = setCheckName(repository, checkName, status, currentTime, "PATCH", commitID, checkName_run_id) | |
} else { | |
getStatusCode = setCheckName(repository, checkName, status, previousDay, "POST", commitID) | |
} | |
if (!(getStatusCode in [200,201])) { | |
error "Failed to create a check run, status code: ${getStatusCode}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment