def updateGithubCommitStatus()

in jenkins-pipeline-shared-libraries/vars/githubscm.groovy [617:645]


def updateGithubCommitStatus(String checkName, String state, String message, String repository = '') {
    println "[INFO] Update commit status for check ${checkName}: state = ${state} and message = ${message}"

    if (!repository) {
        println '[INFO] No given repository... Trying to guess it from current directory'
        repository = getGitRepositoryName()
    }
    println "[DEBUG] repository name = ${repository}"

    if (!getCommitStatusRepoURLEnv(repository) || !getCommitStatusShaEnv(repository)) {
        println '[INFO] Commit status info are not stored, guessing from current repository'
        setCommitStatusRepoURLEnv(repository)
        setCommitStatusShaEnv(repository)
    }
    println "[DEBUG] repo url = ${getCommitStatusRepoURLEnv(repository)}"
    println "[DEBUG] commit sha = ${getCommitStatusShaEnv(repository)}"

    try {
        step([
            $class: 'GitHubCommitStatusSetter',
            commitShaSource: [$class: 'ManuallyEnteredShaSource', sha: getCommitStatusShaEnv(repository)],
            contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: checkName],
            reposSource: [$class: 'ManuallyEnteredRepositorySource', url: getCommitStatusRepoURLEnv(repository)],
            statusResultSource: [ $class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', message: message, state: state]] ],
        ])
    } catch(err) {
        println "Error updating commit status: ${err}"
    }
}