Quality gate status on Sonarcloud with private repos

Hi,

I was using public repo and could do a :

curl -sL https://sonarcloud.io/api/qualitygates/project_status?projectKey=abcd

{“projectStatus”:{“status”:“OK”,“conditions”:[{“status”:“OK”,“metricKey”:“new_lines_to_cover”,“comparator”:“GT”,“periodIndex”:1,“errorThreshold”:“0”,“actualValue”:“0”}],“periods”:[{“index”:1,“mode”:“days”,“date”:“2019-10-30T16:36:31+0100”,“parameter”:“30”}],“ignoredConditions”:false}}

But with a private repo I am not able to do that.
I tried with
curl -L -v -u mustafa.turabali:P****** https://sonarcloud.io/api/qualitygates/project_status?projectKey=abcd

but not working , can you please help.

Julien Lancelot
can you assist?

Hi,

Please do not directly mention people. You won’t’ receive an answer faster by doing so.

As mentioned in the documentation, you have to create a token and use it as a replacement for your login in basic auth.
So it would be:
curl -L -v -u <your-token>: https://....

3 Likes

I’m using your curl command with a token and still having problems:

curl -L -v -u myToken: https://sonarcloud.io/api/qualitygates/project_status?projectKey=myProjectKey

I get the following

{"errors":[{"msg":"Component key 'myProjectKey' not found"}]}

You’ll need to define your organization as a query parameter as well.

Thanks. Looks like the docs need updating. That param isn’t listed. https://sonarcloud.io/web_api/api/qualitygates/project_status

Thanks for the heads up. I’ll ping around :slight_smile: