Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-12369

Cannot run SonarQube if run with locally built sources

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.9.1
    • Fix Version/s: 8.0
    • Component/s: None
    • Labels:
      None
    • Edition:
      Community
    • Production Notes:
      None

      Description

      The problem

      When building SQ from the source of a released version downloaded from https://github.com/SonarSource/sonarqube/releases, the build succeeds but SQ fails at startup with the error such as the following:

      2019.07.27 21:26:23 ERROR web[o.s.s.p.Platform] Web server startup failed
      java.lang.NumberFormatException: For input string: “null”
      at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.base/java.lang.Long.parseLong(Long.java:692)
      at java.base/java.lang.Long.parseLong(Long.java:817)
      at org.sonar.api.utils.Version.parseFieldAsLong(Version.java:175)
      at org.sonar.api.utils.Version.parse(Version.java:137)
      at org.sonar.api.internal.MetadataLoader.loadVersion(MetadataLoader.java:50)
      at org.sonar.server.platform.platformlevel.PlatformLevel1.configureLevel(PlatformLevel1.java:87)
      at org.sonar.server.platform.platformlevel.PlatformLevel.configure(PlatformLevel.java:74)
      at org.sonar.server.platform.Platform.start(Platform.java:208)
      at org.sonar.server.platform.Platform.startLevel1Container(Platform.java:170)
      at org.sonar.server.platform.Platform.init(Platform.java:86)
      

      The cause if the following piece of code in `gradle.build` of module `sonar-plugin-api`:

      'project.buildVersion': project.version.endsWith('SNAPSHOT') ? project.version : on3Digits(project.version) + '.' + System.getProperty("buildNumber")
      

      When version is not a snapshot, buildVersion is made of 3 digits concatenated with the value of system property `buildNumber`. This system property is set when building on Travis or CirrusCI, but it is not on the user's machine. The result is that `buildNumber` value has the `null` string as buildNumber and this makes parsing of the version fail at SQ's startup.

      Steps to reproduce : 

      Download a release zip from this repository : https://github.com/SonarSource/sonarqube/releases

      Execute a ./gradlew build on it

      Unzip the created zip in \sonar-application\build\distributions

      Launch the wanted binary (for me it was StartSonar.bat on windows-x86-64

      Error should occur. 

      Workaround

      Option 1

      Define system property buildNumber to value 0 when building:

      ./gradlew build -DbuildNumber=1
      

      Option 2

      In file sonar-plugin-api/build.gradle, replace the line:

          'project.buildVersion': project.version.endsWith('SNAPSHOT') ? project.version : on3Digits(project.version) + '.' + System.getProperty("buildNumber"),
      

      by

          'project.buildVersion': project.version.endsWith('SNAPSHOT') ? project.version : on3Digits(project.version) + '.' + (System.getProperty("buildNumber") ?: '0'),
      

       

        Attachments

          Activity

            People

            Assignee:
            sebastien.lesaint Sebastien Lesaint
            Reporter:
            mickael.caro Mickaël Caro
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: