use of io.jenkins.blueocean.blueocean_bitbucket_pipeline.HttpResponse in project blueocean-plugin by jenkinsci.
the class BitbucketServerApi method getDefaultBranch.
@Override
@CheckForNull
public BbBranch getDefaultBranch(@Nonnull String orgId, @Nonnull String repoSlug) {
try {
HttpResponse response = request.get(String.format("%s/%s/repos/%s/branches/default", baseUrl + "projects", orgId, repoSlug));
int status = response.getStatus();
// With 5.6.0 its 204, before that it was 404
if (status == 404 || status == 204) {
// empty repo gives 404, we ignore these
return null;
}
InputStream inputStream = response.getContent();
return om.readValue(inputStream, new TypeReference<BbServerBranch>() {
});
} catch (IOException e) {
throw new ServiceException.UnexpectedErrorException(e.getMessage(), e);
}
}
use of io.jenkins.blueocean.blueocean_bitbucket_pipeline.HttpResponse in project blueocean-plugin by jenkinsci.
the class BitbucketApiTest method testAutoRedirectDisabled.
@Test
public void testAutoRedirectDisabled() {
HttpResponse response = new HttpRequest.HttpRequestBuilder(apiUrl).build().get(apiUrl + "/rest/api/1.0/test-redirect");
assertEquals(302, response.getStatus());
assertEquals("http://localhost:7990/bitbucket/rest/api/1.0/redirect-test-success", response.getHeader("Location"));
}
Aggregations