paul paul - 1 year ago 145
Git Question

Set branch non mergeable

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.


Answer Source

For CI/CD on GitHub, this should be fairly simple.

Three Steps:

  1. 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)
  2. Make sure your Jenkins is hooked up appropriately to your GitHub repository. (Most likely via a Webhook)
  3. From the GitHub UI, you are able to specify CI conditions. Go to your Repo, and click Settings -> Branches -> Edit on master (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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download