protected void downloadSampleAxisURLs(File sampleDir, File jobJSONFile) throws Exception {

    JSONObject jobJSONObject =
        JenkinsResultsParserUtil.toJSONObject(
            JenkinsResultsParserUtil.getLocalURL(toURLString(jobJSONFile)));

    int number = jobJSONObject.getInt("number");

    JSONArray runsJSONArray = jobJSONObject.getJSONArray("runs");

    for (int i = 0; i < runsJSONArray.length(); i++) {
      JSONObject runJSONObject = runsJSONArray.getJSONObject(i);

      if (number != runJSONObject.getInt("number")) {
        continue;
      }

      URL runURL = createURL(URLDecoder.decode(runJSONObject.getString("url"), "UTF-8"));

      File runDir = new File(sampleDir, "run-" + i + "/" + number + "/");

      downloadSampleURL(runDir, runURL, "/api/json");
      downloadSampleURL(runDir, runURL, "/logText/progressiveText");
      downloadSampleURL(runDir, runURL, "/testReport/api/json");

      runJSONObject.put("url", toURLString(runDir));
    }

    write(jobJSONFile, jobJSONObject.toString(4));
  }
Пример #2
0
  @Override
  public String getResult() {
    if (!_status.equals("completed")) {
      throw new IllegalStateException("Build not completed");
    }

    String buildURL = getBuildURL();

    if ((result == null) && (buildURL != null)) {
      try {
        JSONObject resultJSONObject =
            JenkinsResultsParserUtil.toJSONObject(buildURL + "api/json?tree=result");

        result = resultJSONObject.optString("result");

        if (result.equals("")) {
          result = null;
        }
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    return result;
  }