Sonarscanner : Get Passed or Failed QualityGate


I am executing sonarcloud in my react App . I run ‘node sonarproject.js’ see the contents of sonarproject.js below. This works perfectly well. I see the results in sonarcloud! However, I would like to know if it passed / failed the quality gate. How do I programatically get thing information out??

const sonarqubeScanner = require(“sonarqube-scanner”);

const { BRANCH_NAME } = process.env;

serverUrl: “”,
token: “mytoken”,
options: {
“sonar.projectName”: “fun”,
“sonar.projectKey”: “funny”,
“sonar.projectBaseDir”: “…/.”,
“sonar.tests”: “./app/src”,
“sonar.test.inclusions”: “app/src/**/test.tsx”,
“sonar.typescript.lcov.reportPaths”: “app/coverage/”,
“sonar.language”: “ts”,
“sonar.sourceEncoding”: “UTF-8”,
“sonar.organization”: “fun”,
“”: “master”,
“Dsonar.scm.provide”: “git”,
() => process.exit()


I think the Measures WebAPI can do what you want:
with parameters component=yourProjectKey and metricKeys=alert_status.


What should the authentication be using the API Token ( generated from User → Security)
curl --location --request GET '

I tried with Base64 of the API Token as well adding it in raw -u APIToken:

I get the following error

“errors”: [
“msg”: “Insufficient privileges”

Using cURL, the token can be passed as copied from the generator page, with the -u parameter and a colon after :

curl -u thetoken: --request GET ''

If you still hit the “Insufficient privileges” error, please make sure the token has been generated by a valid account that has the “Browse” permission on the project.

Thank you, I am all clear - this is the key. Would really help if sonarcloud publishes a Postman collection

curl -u thetoken: --request GET ''
1 Like

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