Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44011

SonarQubeScanner fails the whole plugin in case of SQ with credentials

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • influxdb-plugin
    • None
    • plugin version 1.11, Jenkins version 2.58, SonarQube version 6.3

      Exception:

      [InfluxDB Plugin] SonarQube data found. Writing to InfluxDB...
      ERROR: Build step failed with exception
      net.sf.json.JSONException: A JSONObject text must begin with '{' at character 0 of 
      		 at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:499)
      		 at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:919)
      		 at net.sf.json.JSONObject._fromString(JSONObject.java:1145)
      		 at net.sf.json.JSONObject.fromObject(JSONObject.java:162)
      		 at net.sf.json.JSONObject.fromObject(JSONObject.java:132)
      		 at jenkinsci.plugins.influxdb.generators.SonarQubePointGenerator.getSonarIssues(SonarQubePointGenerator.java:189)
      		 at jenkinsci.plugins.influxdb.generators.SonarQubePointGenerator.generate(SonarQubePointGenerator.java:90)
      		 at jenkinsci.plugins.influxdb.InfluxDbPublisher.perform(InfluxDbPublisher.java:245)
      		 at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
      		 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      		 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      		 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
      		 at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)
      		 at hudson.model.Run.execute(Run.java:1782)
      		 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      		 at hudson.model.ResourceController.execute(ResourceController.java:97)
      		 at hudson.model.Executor.run(Executor.java:405)
      Build step 'Publish build data to InfluxDb target' marked build as failure
      

      Cause: sonarqube runs with credentials. In this case the simple http rest-api request in the SonarQubeScanner returns a non-json string (didn't check if the whole string is empty).
      This leads the a fail of the whole post-build-action and no data is send to the database.

      Workaround
      Create a password "ANALYSIS SUCCESSFUL, you can browse" (name does not care) and inject it to the build. This leads jenkins to mask the string in the log with *** and the scannerpointer will be skipped

      Possible solutions
      1: add an systemproperty or an option to skip the SQ-Scanner even if data is available
      2: use authentication when running the SQ api-request
      3: catch the exception, print an error if you like but do not fail the whole post-build step.

            aleksisimell Aleksi Simell
            zioschild Sven Appenrodt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: