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

InfluxDB cannot collect Sonarqube data

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: influxdb-plugin
    • Labels:
      None
    • Environment:
      InfluxDB plugin 1.20, Jenkins 2.150
    • Similar Issues:

      Description

      InfluxDB fails to collect Sonarqube data with the following error:
      [InfluxDB Plugin] Failed to collect data. Ignoring Exception:net.sf.json.JSONException: A JSONObject text must begin with '{' at character 0 of

       

      I've looked at the code and it seems to be the following issue:
      SonarQubePointGenerator.java line 82:

      url = build.getEnvironment(listener).get("SONAR_HOST_URL");

       

      On my machine (and at work) this call always results in a null value.

       

      On line 86 the following check is done:

      if (url != "") {
          this.sonarServer = url;
      } else {
          this.sonarServer = sonarBuildLink.substring(0,
          sonarBuildLink.indexOf("/dashboard/index/" + this.sonarProjectName));
      }

       

      However, null is not equal to "" so this.sonarServer = url is always called. Therefore the data collection doesn't pull through because the endpoint is set at something like:

      null/api/measures/component?metricKeys=ncloc,complexity,violations&componentKey=

      which isn't a valid url.

       

      Changing if (url != "") to if (url != null && url != "") fixed the issue for me.

        Attachments

          Activity

          Hide
          aleksisimell Aleksi Simell added a comment -

          Changed if statement to check also null values.

          Show
          aleksisimell Aleksi Simell added a comment - Changed if statement to check also null values.

            People

            • Assignee:
              aleksisimell Aleksi Simell
              Reporter:
              wouterman Wouter van der Linde
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: