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

InfluxDB cannot collect Sonarqube data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • influxdb-plugin
    • None
    • InfluxDB plugin 1.20, Jenkins 2.150

      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.

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

              Created:
              Updated:
              Resolved: