2

I'm trying to set github commit status during my steps of Jenkins config. My Jenkinsfile looks like:

void setBuildStatus(String message, String state) {
  step([
      $class: "GitHubCommitStatusSetter",
      reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/my_org/my_repo"],
      contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
      errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
      statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
  ]);
}

pipeline {
    agent any
    
    stages {
        stage('Checkout Code') {
            steps {
                checkout scm
                setBuildStatus("Build started", "PENDING");
            }
        }
        
        stage('Build') {
            steps {
                ...
            }
        }
    }

    post {
      success {
        setBuildStatus("Build succeeded", "SUCCESS");
      }
    failure {
       setBuildStatus("Build failed", "FAILURE");
    }
  }
}

I also have already setup the github server under the global configuration of Jenkins, example scrn: Github Servers configuration

Though, During the build, on the console output i see the following:

[Set GitHub commit status (universal)] PENDING on repos [] (sha:xxxxxx) with context:ci/jenkins/build-status

Or

[Set GitHub commit status (universal)] SUCCESS on repos [] (sha:xxxxxx) with context:ci/jenkins/build-status

The sha is correct. But the repos array is empty... Any ideas?

Versions info:

Jenkins: v2.346.2

Github Plugin Version: 1.34.4

angelos_lex
  • 1,593
  • 16
  • 24

0 Answers0