GitHub: How to configure status checks per Pipeline stage for Pull Requests

Article ID:360052076112
2 minute readKnowledge base

Issue

  • How to change the default status checks for protected branches in GitHub with information from my Pipeline?

  • I would like to set the status checks for protected branches in GitHub per stages of my Jenkinsfile.

Resolution

Prerequisite: GitHub Integration webhook for multibranch type of projects is configured as described in GitHub Integration: Webhooks — CloudBees Support

This issues is solved thanks to the CloudBees SCM Reporting Plugin which sends a GitHub Status check per Jenkinsfile stage definition

Example: The highlight of this example is that the remote status check depends on the build of a downstream job.

pipeline { agent any stages { stage ("local"){ steps{ sh "exit 0" } } stage("remote") { steps{ build "my-team/folder-a/pipeline-1" } } } }

On GitHub side

This section is optional in case you want to make the status checks Required.

After triggering the pipeline for the protected branches (the target branch for your Pull Request) following the configuration in (2/)

3/ Go to the repository Settings > protected branches > check Require status checks to pass before merging > Select the status check you wish to make required for your Pull request.

GH protected branches
Other status checks come from GitHub Integration: Webhooks
  • continuous-integration/jenkins/branch

  • continuous-integration/jenkins/pr-merge

Tested products/plugins version