Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub required status checks from Jenkins for forks vs local branches

I have a GitHub repository established with a Multibranch Pipeline job in Jenkins, and until now have been content to require the continuous-integration/jenkins/branch status check, as Jenkins posts when building a local branch from the repo. However, I've now got a pull request from an external fork, and Jenkins has posted a continuous-integration/jenkins/pr-merge status check for that. And because the continuous-integration/jenkins/branch status check is required, the PR is blocked from being merged.

What's the expected approach here, for a project that will have a combination of local branches (from its primary maintainers) and forks (from occasional outside contributors)? Must I forgo having either of the status checks be required on the GitHub side? Or is there some other way to get Jenkins to post a stable status check context regardless of the PR's source?

like image 958
Nick Jones Avatar asked Oct 12 '17 20:10

Nick Jones


People also ask

How does Jenkins communicate with GitHub?

The primary avenues for integrating your Jenkins instance with GitHub are: "build integration" - using GitHub to trigger builds. "authentication integration" - using GitHub as the source of authentication information to secure a Jenkins instance.

How do I restrict a pull request on GitHub?

Next to "Branch protection rules", click Add rule. Under "Branch name pattern", type the branch name or pattern you want to protect. Optionally, enable required pull requests. Under "Protect matching branches", select Require a pull request before merging.


1 Answers

I had the same issue, with thanks to a helpful colleague I found that, by default, the branch source plugin builds branches that aren't necessarily associated with any pull request.

(Relates to the tickbox "Build origin branches" in the link: https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#_controlling_what_is_built )

This is what creates the status check of "continuous-integration/jenkins/branch".

I unticked that option and ticked the "Build origin PRs (merged with base branch" option, and both status checks now have the same context "continuous-integration/jenkins/pr-merge" and PRs both from forks and branches now trigger the same status check.

In my setup, the tickboxes are in the organisation configuration (since I am also using the GitHub organisation plugin), under Projects > GitHub organisation > Advanced, hopefully on yours, the same options show in your multibranch pipeline config.

Hope this helps

like image 101
Kubbs Avatar answered Sep 21 '22 12:09

Kubbs