Make GH Action Job of Sonarcloud scan fail when quality gate is not passed

When using Github Actions and Sonarcloud, the step in our CI running the code analysis always succeeds no matter the outcome of the quality gate (passed/failed). There are other jobs depending on this information.

In the meantime, is there another way of getting this crucial information in our CI? Lets say getting the latest analysis report for PR 123?

Thanks for your help.


Welcome to the community!

There’s a GitHub check for that.


Hi Ann,

thanks for reaching out, could you point me in the right direction, please? Is there a flag here I missed?

Cheers, Florian

Hello @floriansuchan ,

We are decorating your commits with a SonarCloud GitHub Check called “SonarCloud Code Analysis” that reflects the quality gate status (so it fails when the quality fails and passes otherwise).

You can use this information to block merging the PR, for example: Defining the mergeability of pull requests - GitHub Docs

Hi Martin,

yes, we do see this check. However, I’m not sure if it is possible to reference it from within the workflow. Let’s say we have 3 jobs that are all dependent on the success of the previous one:

tests > sonar cloud > deployment

From what I see the check “SonarCloud Code Analysis” lives outside the workflow, right?

Best, Florian

Yes, that is correct, the check lives outside of that. You can set the sonar.qualitygate.wait=true parameter in your configuration file to make the job wait for the result and pass/fail based on the quality gate.

Could you provide more details about the following jobs so that we can better understand your use case?

1 Like

Hi Martin,

thanks for your response, this was exactly what we were looking for, it works as expected! One last question: In the logs for the job is says “Waiting for the analysis report to be processed (max 300s)”. It was fast, as the project is still small but do you know if we will eventually hit that limit?

Have a nice Sunday, best,

Hello @floriansuchan ,

Happy to hear that it works! You shouldn’t run into the timeout normally. Please feel free to create a new thread if you ever do.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.