public BuildWithDetails details() throws IOException { return client.get(url, BuildWithDetails.class); }
public JobWithDetails details() throws IOException { return client.get(url, JobWithDetails.class); }
public ComputerWithDetails details() throws IOException { return client.get("/computer/" + displayName.replaceAll("master", "(master)"), ComputerWithDetails.class); }
/** * {@inheritDoc} */ @Override public <T extends BaseModel> T getQuietly(String path, Class<T> cls) { T value; try { value = get(path, cls); return value; } catch (IOException e) { LOGGER.debug("getQuietly({}, {})", path, cls.getName(), e); // TODO: Is returing null a good idea? return null; } }
/** * Get the xml description of an existing job * * @return the new job object * @throws IOException */ public String getJobXml(String jobName) throws IOException { return client.get("/job/" + encode(jobName) + "/config.xml"); }
/** * Get the description of an existing Label * * @return label object * @throws IOException */ public LabelWithDetails getLabel(String labelName) throws IOException { return client.get("/label/" + encode(labelName), LabelWithDetails.class); }
/** * Get a list of all the defined jobs on the server (at the summary level) * * @return list of defined jobs (summary level, for details @see Job#details * @throws IOException */ public Map<String, Job> getJobs() throws IOException { List<Job> jobs = client.get("/", MainView.class).getJobs(); return Maps.uniqueIndex(jobs, new Function<Job, String>() { @Override public String apply(Job job) { job.setClient(client); return job.getName().toLowerCase(); } }); }
/** * Get a list of all the computers on the server (at the summary level) * * @return list of defined computers (summary level, for details @see Computer#details * @throws IOException */ public Map<String, Computer> getComputers() throws IOException { List<Computer> computers = client.get("computer/", Computer.class).getComputers(); return Maps.uniqueIndex(computers, new Function<Computer, String>() { @Override public String apply(Computer computer) { computer.setClient(client); return computer.getDisplayName().toLowerCase(); } }); }
public List<JenkinsJobBuildParameter> getBuildParams(String jobName){ try{ String jobJson = jenkinsHttpClient.get(new URI(jenkins.getJob(jobName).getUrl()).getPath()); logger.debug("Complete jobJson: " + jobJson); return parseJsonGetBuildParams(jobJson); }catch (Exception e){ logger.error("Failed to get build parameters for job: " + jobName); e.printStackTrace(); throw new BentenJenkinsException(e.getMessage()); } }
public String Stop() throws HttpResponseException, IOException{ try { return client.get(url + "stop"); } catch (IOException ex){ if(((HttpResponseException)ex).getStatusCode() == 405) { stopPost(); return ""; } } return ""; }
/** * {@inheritDoc} */ @Override public HttpResponse post_form_with_result(String path, List<NameValuePair> data, boolean crumbFlag) throws IOException { HttpPost request; if (data != null) { UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(data); request = new HttpPost(UrlUtils.toNoApiUri(uri, context, path)); request.setEntity(urlEncodedFormEntity); } else { request = new HttpPost(UrlUtils.toNoApiUri(uri, context, path)); } if (crumbFlag == true) { Crumb crumb = get("/crumbIssuer", Crumb.class); if (crumb != null) { request.addHeader(new BasicHeader(crumb.getCrumbRequestField(), crumb.getCrumb())); } } HttpResponse response = client.execute(request, localContext); jenkinsVersion = ResponseUtils.getJenkinsVersion(response); return response; }
/** * {@inheritDoc} */ @Override public String post_text(String path, String textData, ContentType contentType, boolean crumbFlag) throws IOException { HttpPost request = new HttpPost(UrlUtils.toJsonApiUri(uri, context, path)); if (crumbFlag == true) { Crumb crumb = get("/crumbIssuer", Crumb.class); if (crumb != null) { request.addHeader(new BasicHeader(crumb.getCrumbRequestField(), crumb.getCrumb())); } } if (textData != null) { request.setEntity(new StringEntity(textData, contentType)); } HttpResponse response = client.execute(request, localContext); jenkinsVersion = ResponseUtils.getJenkinsVersion(response); try { httpResponseValidator.validateResponse(response); return IOUtils.toString(response.getEntity().getContent()); } finally { EntityUtils.consume(response.getEntity()); releaseConnection(request); } }
@Before public void setUp() throws Exception { when(client.get("/", MainView.class)).thenReturn(mainView); }
@Test public void testGetJobXml() throws Exception { String jobName = "pr"; String xmlString = "<xml>some xml goes here</xml>"; Mockito.when(client.get(Mockito.anyString())).thenReturn(xmlString); String xmlReturn = server.getJobXml(jobName); Mockito.verify(client).get("/job/pr/config.xml"); assertEquals(xmlString, xmlReturn); }
Crumb crumb = get("/crumbIssuer", Crumb.class); if (crumb != null) { request.addHeader(new BasicHeader(crumb.getCrumbRequestField(), crumb.getCrumb()));
/** * Get a single Job from the server. * * @return A single Job, null if not present * @throws IOException */ public JobWithDetails getJob(String jobName) throws IOException { try { JobWithDetails job = client.get("/job/"+encode(jobName),JobWithDetails.class); job.setClient(client); return job; } catch (HttpResponseException e) { if(e.getStatusCode() == 404) { return null; } throw e; } }