Unable to setup github rule to prevent PR merge

I cannot figure out how to setup a GitHub rule to block PR merge if Sonar PR analysis failed. We have GitHub for SCM but our CI is CircleCI. We run the Sonar Analysis scan in the CircleCI pipeline. In GitHub, I can see the Sonar Analysis decoration for a PR; however, I don’t see Sonar in the “All checks have passed” list. When I try to setup the branch protection rule, I don’t see the “SonarQube Code Analysis” option under “Require status checks to pass”.

I did a little bit of searching on the forums and discovered this post: How to block the merge of Pull Requests when SonarQube Quality Gate is failed, with GitHub

Any helps will be appreciated?

Thanks,

Hi,

It looks like you want to add sonar.qualitygate.wait to your analysis parameters. Per the docs, this:

Forces the analysis step to poll the server instance and wait for the Quality Gate status. This setting will fail the pipeline if the quality gate fails.

 
HTH,
Ann

That is one option we can explore; we’ll need to modify the CirclCi orb for that.

SonarQube has two analysis methods, automatic and CI based. We are using the CI based currently. Does automatic analysis will give the option in branch ruleset to block merge?

Thanks,

Jared

Hi Jared,

Automatic analysis would run entirely independently of your CI, so you would have no way of reflecting quality gate status back into your pipeline.

 
HTH,
Ann