1

I am attempting to set the leak period in SonarQube 5.6.5 using Sonar Scanner with a properties file or command line argument, but I am having no success.

I would like to set the sonar.timemachine.period1 property to a specific version, e.g., 1.0.0, as is mentinoned in solution 2 (using sonar-project.properties) or solution 3 (using command line paramter, e.g., -Dsonar.timemachine.period1=1.0.0) of the accepted answer for Sonar runner, seeonly newly introduced issues.

Here is the scenario that reproduces my issue.

  1. Run analysis with sonar.projectVersion=1.0.0.
  2. Run analysis with sonar.projectVersion=2.0.0 and sonar.timemachine.period1=1.0.0.
  3. Run analysis with sonar.projectVersion=3.0.0 and sonar.timemachine.period1=1.0.0.

After the second and third analysis I would expect the leak period to be "since 1.0.0" (which is the behavior if I manually set the leak period in the SonarQube admin section to 1.0.0). Instead, for the third analysis the leak period is being set to 2.0.0.

What am I missing? Is this a bug?

Community
  • 1
  • 1
tgd25
  • 48
  • 1
  • 7

2 Answers2

2

Setting the sonar.timemachine.period1 via 'normal' property is not sufficient, you will need to set properties via REST Api - note you'll need admin rights.
Had the same problem when using the Sonarqube Ant Task and created a macrodef for that purpose.
See :
Sonarqube Wep API documentation
Sonarqube set leak period to specific version other than previous version

Community
  • 1
  • 1
Rebse
  • 10,307
  • 2
  • 38
  • 66
  • FYI, there's an open feature request at https://community.sonarsource.com/t/make-sonar-leak-period-an-analysis-parameter/13798 to support setting the leak period on a per-scan basis. – Noyo Sep 07 '19 at 17:23
1

Rebse is correct, you must use the API to set the sonar.timemachine.period1 property. I'm not using Ant. I used a curl command from Bamboo.

curl
-X POST 
-u MY_USERNAME:MY_PASSWORD 
-d resource=MY_PROJECT_KEY
-d id=sonar.timemachine.period1 
-d value=1.0.0
http://localhost:9000/api/properties
tgd25
  • 48
  • 1
  • 7
  • You may create a usertoken - See My Account / security - and use -u usertoken: instead of username:password, means usertoken followed by separator: and empty password. – Rebse Apr 14 '17 at 10:29