问题
I would like to mark my branch as non mergeable, if my jenkins pipeline is not green.
The idea is avoid people in the team to merge a branch into master if the pipeline for that branch in Jenkins is not green.
Any idea is there´s any jenkins plugins to make this happens in Github webPage?. The idea like I said is, that if for example my branch has some failures, do not allow click the merge button in github page for that branch.
Regards.
回答1:
For CI/CD on GitHub, this should be fairly simple.
Three Steps:
- Ensure that the Deployment step from jenkins is only on "After Success". You don't want to allow anything if the step isn't green (as you say)
- Make sure your Jenkins is hooked up appropriately to your GitHub repository. (Most likely via a Webhook)
- From the GitHub UI, you are able to specify CI conditions. Go to your Repo, and click
Settings
->Branches
->Edit
onmaster
(or whatever your default branch is).
There is a checkbox, on the Branches page called "Require status checks to pass before merging"
. By checking this, you will be graying out every "Merge Pull Request" button unless your CI/CD steps pass.
来源:https://stackoverflow.com/questions/40221242/set-branch-non-mergeable