0

The idea is that I want to block pull requests on GitHub if a build fails on Jenkins so that potential bad code doesn't get merged

I had originally found a plugin called Pipeline GitHub Notify Step: https://www.jenkins.io/doc/pipeline/steps/pipeline-githubnotify-step/ that uses

githubNotify

but then I found out from this link https://plugins.jenkins.io/pipeline-githubnotify-step/ that we should use the github-checks-plugin instead of the Pipeline GitHub Notify. I don't know if its because its depreciated or they just added similar features to the github-checks-plugin but I decided to just install the GitHub Checks Plugin. Afterwards I opened a PR on GitHub with code I knew would fail the build then ran a test build on Jenkins with the impression that GitHub would block my PR due to the bad build but it didn't I went under settings->branch and enabled Require status checks to pass before merging but it didn't block my PR because of the failed build. In fact it still doesn't even notice the failed build. Maybe I'm missing another plugin or perhaps there was something I forgot to enable.

DevopitionBro
  • 111
  • 1
  • 6
  • There is a [GitHub plugin](https://plugins.jenkins.io/github/) that reports status back to GitHub, and that check can then be used for branch protection. – Benjamin W. Nov 04 '22 at 14:29
  • @BenjaminW. I have GitHub plugin installed. But my PR on GitHub still doesn't notice that my build failed on Jenkins. Is there something that I need to enable in addition to Require status checks? – DevopitionBro Nov 04 '22 at 14:38
  • You need to add a personal access token of a GitHub user with sufficient permissions at `/jobs/YOURORG/configure` (General tab), and then set your jobs to use that in a post-build step. [This Q&A](https://stackoverflow.com/q/14274293/3266847) covers most of that, but it all depends on your Jenkins version. – Benjamin W. Nov 04 '22 at 16:34

0 Answers0