Get quality gate result from SonarCloud analysis with GitHub Actions


My team and I are using SonarCloud with GitHub Actions in order to analice a React App. We create the project using the command npm create-react-app my-app. We were able to create the project in SonarCloud, set the Quality Gate using Sonar way and for the integration we are using SonarCloud Scan.

However, we want to implement something (I’ve been searching for a while and I haven’t found if it’s possible).

Is it possible to get the result from the quality gate when the analysis has finished?

We want for example if the Quality gate fails, stop the building process and finished the execution of the pipeline or if the Quality gate it’s ok, continue with the next steps.

Even if it fails, the console log shows a EXECUTION SUCCESS.


Hi Joseph,

Welcome to the community!

In the current SonarCloud GitHub Action there is no built-in mechanism to fail a build based on the status of the quality gate. As you noticed, the build fails or succeeds based on whether the scanner successfully completes its scan, regardless of the resulting QG status.

But, all the information is available for you to build your own logic to fail the build by using the web API.

Basically you need to query the status of the QQ using this API:

And then build the logic to fail the build based on that.

To query the status you first need the task ID. This is available either by extracting it from the scanner output, for example, the scanner logs lines like

INFO: More about the report processing at

(you could parse that and get the value of the query param id)

or you could get the task id via the API too using

Of course, this is very much a DIY approach, but I believe currently this is the only way to do it.

I hope this helps.

Thank you very much for your help Peeter!
I agree with you that it’s a very DIY approach but I will give it a try, it’s worth it.

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