Configuring Housekeeping on Boot

Hello,

Using the latest and greatest in SonarQube 8.3.1, booting and configuring on a Centos EC2 in AWS. Is there a way to automate changing the housekeeping defaults without using the Administration tab in the UI? From what I saw in the config files (sonarqube.properties, etc.) there doesn’t seem to be anything I can adjust as it pertains to housekeeping or age of metrics. I’d like to start off by changing the max life of metrics from 5 years to 1 year.

Hello Taylor,

As a general tip: if you can do it from the SonarQube UI, then you can almost certainly do it via a call to our web API. In this case, if you spied on our Housekeeping settings page using your browser developer tools as you changed any of those properties, you’d notice that we call api/settings/set to accomplish changing any of those values.

The web API documentation is embedded within SonarQube, link at the footer of each page.

Hope this helps!

Jeff,

Thanks for the prompt response! Yes, I see what you’ve described regarding the API calls - I missed that when going through the web_api/api page. I assume then that I will have to make the call within the EC2’s user data after SonarQube has been installed.

One last question: I see that a requirement for making said API call is either ‘Administer System’ or ‘Administer’ rights permissions; is there anything extra I would need to do if running the POST set call to make sure permissions are okay, assuming this is run as root during the initialization? I’ve never had to make an API call from the user data before.

Thanks again for your help!

For credentials, you can pass a username and password for a user with admin access or (probably better) pass a token as the username value. E.g. something like

curl -u tokenval: -X POST -d "sonar.foo=bar" http://sonar.host:9000/api/settings/set

Note the use of the trailing colon after tokenval if using a utility like curl, it’s needed to indicate there’s no password to be sent.

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