Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Github plugin doesn't set status

I'm trying to set a github status from a Jenkins job. Jenkins returns a

[Set GitHub commit status (universal)] SUCCESS on repos [] (sha:9892fbd) with context:ci/jenkins/tests

... but the status isn't set when I query it with the REST API later.

There's the groovy code:

def getCommitHash() {
    sh(script: """
git rev-parse HEAD
""", returnStdout: true).trim()
}


def setCountTestLocation(String location) {
    url = "https://<internal github>/<org>/<repo>"
    commitHash = getCommitHash()
    print(url)
    print(commitHash)
    step([
            $class: "GitHubCommitStatusSetter",
            reposSource: [$class: "ManuallyEnteredRepositorySource", url: url],
            contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/tests"],
            statusBackrefSource: [$class: "ManuallyEnteredBackrefSource", backref: location],
            errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
            commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitHash],
            statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: "Tests here!", state: "SUCCESS", location: location]] ]
        ]);
}
like image 402
Reactormonk Avatar asked Oct 29 '22 20:10

Reactormonk


2 Answers

You repository hasn't been updated as it seems that repos were not properly set.
Plugin still reports success as it properly completed its run, but repo list is empty as evident in your message SUCCESS on repos [].

like image 104
Goran Brkic Avatar answered Dec 04 '22 22:12

Goran Brkic


This issue can occur if you have not set up a "GitHub Server" config under the global Jenkins configs:

Manage Jenkins -> Configure System -> GitHub

You can find more details on how to set up a server configuration under the "Automatic Mode" section of the GitHub Plugin documentation:

https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin#GitHubPlugin-AutomaticMode%28Jenkinsmanageshooksforjobsbyitself%29

like image 22
foobar1101 Avatar answered Dec 04 '22 22:12

foobar1101