Skip to content

Instantly share code, notes, and snippets.

@naturalett
Created February 23, 2020 22:30
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 naturalett/5497023f57a86d38c265dd5d0c932d68 to your computer and use it in GitHub Desktop.
Save naturalett/5497023f57a86d38c265dd5d0c932d68 to your computer and use it in GitHub Desktop.
getPreviousCheckNameRunID
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