Hi there,
I'm trying to figure out how to prevent the PR merge when SonarCloud quality gate fails, ie. when the build fails.
I have :
- a step in bitbucket-pipelines.yml to analyse on SonarCloud and fails if the Quality Gate fails for PRs
- a premium plan
- created branching permission with the following properties :
branch type : feature
I've checked "Check the last commit for at least 3 successful builds and no failed builds and checked "Prevent a merge with unresolved merge checks"
I can still merge with a PR on a branch called "feature/issues", whereas I have 1 build failed (the SonarCloud) out of 3.
I tried to check "Check for at least 1 approval" and I can still merge if no one has approved the PR.
I also tried with a new PR, but I can still merge. I'm out of ideas, can you help me configure everything to prevent the merge of PRs please?
Thanks !
Hello @aurelie-boiteux-sonarsource,
So you mentioned that you set the branch permission for branch type : feature. This references the branching model – maybe the branch you're trying to merge a PR from is not matching the pattern of a feature branch, so the permission rules don't apply?
If you want to prevent a PR from any branch from being merged, set up branch permission for pattern * instead – this will be in force for any branch in your repository.
Hope this helps. Let me know what you find.
Cheers,
Daniil
Hi @Daniil Penkin ,
Thanks for your answer!
I tried with pattern *, but I can still merge. Also I tried to check as well for one approval, I can still merge. It is effective right away, I don't need to relaunch the PR pipeline, right ?
I'll put the screenshot of my branch permissions, maybe it can help, the branching model is the one by default.
Also, what I see on the PR:
Thanks a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for clarification @aurelie-boiteux-sonarsource.
When you say you can merge such PR, do you mean that you can actually click through the dialog, and the branch would be merged?
If, however, you mean that the Merge button remains active and opens the dialog, which in turn has another active Merge button, but you haven't tried to proceed with a merge, then I know the answer :)
The merge dialog and even the merge button in that dialog indeed remain enabled even with some failed merge checks in the new PR experience which you're using by the look of the last screenshot.
At the moment you'll get a list of failed merge checks only when you click on the Merge button inside of the dialog. This is indeed confusing, and such behaviour is a temporary solution while the team continues to work on the new PR experience. Please take a look at this thread to get some preview of what it's going to look like.
You can also switch to the old PR experience: there's a link in the very bottom of the right sidebar to do that just once for your PR, or you can go to Labs in your Bitbucket settings and disable "New pull request experience" feature. The old PR experience surfaces the failed merge checks as soon as you try clicking on Merge button on the page, e.g. it won't show the dialog.
Please let me know if my assumption about what you meant is correct.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.