예제 #1
0
  /**
   * get latest build number
   *
   * @param jobName
   * @return
   * @throws JSONException
   */
  public int getLastBuildNumber(String jobName) throws JSONException {

    String getUrl = jenkinsUrl + "/job/" + jobName + "/lastBuild" + API;

    JSONObject responseJson = runHttp(client, context, getUrl);

    return responseJson.getInt("number");
  }
예제 #2
0
  /**
   * check if build finished
   *
   * @param jobName
   * @param buildNumber
   * @return
   * @throws JSONException
   */
  public boolean isBuildFinished(String jobName, int buildNumber) throws JSONException {

    String getUrl = jenkinsUrl + "/job/" + jobName + "/" + buildNumber + API;
    JSONObject responseJson;
    responseJson = runHttp(client, context, getUrl);
    if (responseJson == null) {
      return false;
    }

    return (!Boolean.parseBoolean(responseJson.getString("building"))
        && responseJson.getInt("duration") > 0);
  }