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

SonarQubeScanner fails the whole plugin in case of SQ with credentials

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: influxdb-plugin
    • Labels:
      None
    • Environment:
      plugin version 1.11, Jenkins version 2.58, SonarQube version 6.3
    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          aleksisimell Aleksi Simell added a comment -

          Solution 3 is already available from global settings by unchecking the exposeExceptions checkbox.

          I was working on solution 1 already for some time by having a checkbox for all the data you want to send. However, I had some issues with that approach, and solution 3 provided the required workaround at that time, so I didn't continue my development. Maybe it's time I started it again.

          Show
          aleksisimell Aleksi Simell added a comment - Solution 3 is already available from global settings by unchecking the exposeExceptions checkbox. I was working on solution 1 already for some time by having a checkbox for all the data you want to send. However, I had some issues with that approach, and solution 3 provided the required workaround at that time, so I didn't continue my development. Maybe it's time I started it again.
          Hide
          zioschild Sven Appenrodt added a comment -

          Found the checkbox... but it is unchecked.. Seems this exception is thrown even with unchecked option The option will work on "writeToInflux" but not directly in the scanner. And because of it is not an IOExeption ith will not be catched...

          Show
          zioschild Sven Appenrodt added a comment - Found the checkbox... but it is unchecked.. Seems this exception is thrown even with unchecked option The option will work on "writeToInflux" but not directly in the scanner. And because of it is not an IOExeption ith will not be catched...
          Hide
          aleksisimell Aleksi Simell added a comment -

          That is an excellent point. I'll start working on a fix for this. As a hotfix I will probably ignore errors received from data generation.

          Show
          aleksisimell Aleksi Simell added a comment - That is an excellent point. I'll start working on a fix for this. As a hotfix I will probably ignore errors received from data generation.
          Hide
          aleksisimell Aleksi Simell added a comment -

          I added a fix for the plugin to ignore errors in data generation. Closing the issue as fixed.

          Show
          aleksisimell Aleksi Simell added a comment - I added a fix for the plugin to ignore errors in data generation. Closing the issue as fixed.
          Hide
          aleksisimell Aleksi Simell added a comment -

          Issue fixed. See previous comment.

          Show
          aleksisimell Aleksi Simell added a comment - Issue fixed. See previous comment.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: