What I am trying to achieve:
To update my project’s “new code” start date (aka, ‘leak period’) to be a specific date via the API
Problem encountered:
Using the info found in api/settings, I attempted to use POST api/settings/set to update the value. I tried to do this through REST API and then cURL. With both, a 400 Bad Request code was returned along with the following error message: “The ‘key’ parameter is missing”
What I need
A solution as to why the error message The 'key' parameter is missing is generated when key is clearly being used as a parameter.
Details:
SonarQube Version: Community 10.2.1.78527
SQ Deployment: unknown
I have ensured that the token was created for the correct project, in the correct environment, and that it’s for an account w/ ‘sonar-administrators’ and ‘sonar-users’ access
Thanks for the suggestion, Colin. I tried it out and got a 204 code - “No Content” - when executed.
I then ran the second POST suggested at the bottom of “New code definition in SonarCloud” (see link above): POST https://<my_URL>/api/settings/set?key=sonar.leak.period.type&component=<my_project>&value=date. This also returned a 204.
To see if this worked, I checked in two places: the SQ page for the project and also the value of leakPeriodDate in the API for the project (GET https://<my_URL>/api/components/show?component=<my_project>). Neither place showed an updated value for “new code”.
I re-read your post and realize what’s going on – sonar.leak.period is no longer used to control the New Code Period in the latest versions of SonarQube, and this has been the case since SonarQube v8.0.
New code: period values simplified
It’s now easier to set your new code period in the UI. With the new settings, specific analysis has replaced setting the new code period to a specific date or version. If you were using a specific date or version for your new code period, now you’ll need to use a specific analysis. See the Setting your new code period for more info.
An additional takeaway from that upgrade note – you can no longer set a specific date.