Created
February 23, 2020 22:30
-
-
Save naturalett/5497023f57a86d38c265dd5d0c932d68 to your computer and use it in GitHub Desktop.
getPreviousCheckNameRunID
This file contains hidden or 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
ORGANIZATION_NAME = <ORGANIZATION_NAME> | |
def getPreviousCheckNameRunID(repository, commitID, token, checkName) { | |
try { | |
def httpConn = new URL("https://api.github.com/repos/${ORGANIZATION_NAME}/${repository}/commits/${commitID}/check-runs").openConnection(); | |
httpConn.setDoOutput(true) | |
httpConn.setRequestProperty( 'Authorization', "token ${token}" ) | |
httpConn.setRequestProperty( 'Accept', 'application/vnd.github.antiope-preview+json' ) | |
checkRuns = httpConn.getInputStream().getText(); | |
def slurperCheckRun = new JsonSlurper() | |
def resultMapCheckRun = slurperCheckRun.parseText(checkRuns) | |
def check_run_id = resultMapCheckRun.check_runs | |
.find { it.name == checkName } | |
.id | |
return check_run_id | |
} catch(Exception e){ | |
error 'Failed to retrieve the check id' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment