Example #1
0
 public void init() {
   if (httpClient == null) {
     RequestConfig.Builder requestBuilder = RequestConfig.custom();
     requestBuilder = requestBuilder.setConnectTimeout(bookmakerConfig.getTimeout());
     requestBuilder = requestBuilder.setConnectionRequestTimeout(bookmakerConfig.getTimeout());
     HttpClientBuilder builder = HttpClientBuilder.create();
     builder.setDefaultRequestConfig(requestBuilder.build());
     httpClient = builder.build();
   }
 }
Example #2
0
 public String retrieveDownloadVersionForJob(final String jobName)
     throws IOException, JSONException {
   releasePostfix = bookmakerConfig.getReleasePostfix();
   final String retrieveDownloadVersionsUrl =
       String.format(
           JENKINS_JOB_DOWNLOAD_VERSION_URL,
           bookmakerConfig.getHost(),
           bookmakerConfig.getPort(),
           jobName,
           releasePostfix);
   final String content = retrieveUrlContent(retrieveDownloadVersionsUrl);
   return retrieveDownloadVersionFromJson(content);
 }
Example #3
0
 public List<String> retrieveJobNames() throws IOException, JSONException {
   releasePostfix = bookmakerConfig.getReleasePostfix();
   final List<String> jobNames = new ArrayList<>();
   final String content =
       retrieveUrlContent(
           String.format(JENKINS_JOBS_URL, bookmakerConfig.getHost(), bookmakerConfig.getPort()));
   final JSONObject json = new JSONObject(content);
   final JSONArray jobs = json.getJSONArray("jobs");
   for (int i = 0; i < jobs.length(); i++) {
     final JSONObject job = jobs.getJSONObject(i);
     final String jobName = job.getString("name");
     if (jobName.endsWith(releasePostfix)) {
       jobNames.add(job.getString("name").replace(releasePostfix, ""));
     }
   }
   return jobNames;
 }