Search code examples
sonarqubesonar-runnersonarqube-scan

Does setting sonar.timemachine.period1 from config or command line work?


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?


Solution

  • 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