Unable to set sonar.autoscan.enabled via Web API

  • Error observed
{
    "errors": [
        {
            "msg": "Setting 'sonar.autoscan.enabled' cannot be set on a Project"
        }
    ]
}
  • Steps to reproduce
    Perform a POST call to https://sonarcloud.io/api/settings/set?component=my-project-key&key=sonar.autoscan.enabled&value=false where my-project-key is an existing project.

  • Potential workaround
    I did find an endpoint api/autoscan/activation that is called from the frontend that allows you to successfully set this setting, which will work for my use case, but I have reservations about using an endpoint that as far as I can tell is undocumented.

This does not appear to be a permissions issue as I’ve verified I can set other settings via the API, and have tried across both my personal user and the service account we’re using for this automation. Thanks in advance for any help on this.

Hi,

Welcome to the community!

The endpoints whose documentation you can’t see are non-public. That means they could change without warning. So you’re right to be leery of using them.

Since this is an issue, I presume, of automating your workflows, then the supported route here would be to touch sonar-project.properties in each project you add. Per the docs:

  • SonarQube Cloud will reject a project for automatic analysis if it contains a sonar-project.properties file

 
HTH,
Ann

Thanks for the response, unfortunately this doesn’t help solve for my current use case. It’s not feasible right now to include that file with every project at creation time - we can potentially look at doing that down the line though, if it’s the only solution.

Just to confirm, there is no official API support for this? That’s quite a feature gap if so :frowning: how could I raise a feature request?

Hi,

This thread would be the way. Could yo flesh-out your need and use case?

 
Thx,
Ann