aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/jenkinsci/plugins/bbprb/BitbucketBuildTrigger.java12
-rw-r--r--src/main/java/org/jenkinsci/plugins/bbprb/bitbucket/ApiClient.java17
2 files changed, 13 insertions, 16 deletions
diff --git a/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketBuildTrigger.java b/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketBuildTrigger.java
index 0cbd857..cc4b285 100644
--- a/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketBuildTrigger.java
+++ b/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketBuildTrigger.java
@@ -109,9 +109,9 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
all, CredentialsMatchers.withId(this.credentialsId));
if (creds != null) {
logger.log(Level.INFO, "Creating Bitbucket API client");
- this.apiClient = new ApiClient(
- creds.getUsername(), creds.getPassword().getPlainText(),
- this.destinationRepository, this.ciKey, this.ciName);
+ this.apiClient = new ApiClient(creds.getUsername(),
+ creds.getPassword().getPlainText(),
+ this.ciKey, this.ciName);
} else {
logger.log(Level.SEVERE, "Credentials `{0}` not found",
this.credentialsId);
@@ -126,9 +126,9 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
logger.log(Level.INFO, "Setting status of PR #{0} to {1} for {2}",
new Object[] {cause.getPullRequestId(), state,
cause.getDestinationRepository()});
- this.apiClient.setBuildStatus(cause.getSourceCommitHash(), state,
- getInstance().getRootUrl() + path, null,
- this.job.getFullName());
+ this.apiClient.setBuildStatus(
+ cause.getSourceRepository(), cause.getSourceCommitHash(), state,
+ getInstance().getRootUrl() + path, null, this.job.getFullName());
} else {
logger.log(Level.INFO,
"Will not set Bitbucket PR build status (not configured)");
diff --git a/src/main/java/org/jenkinsci/plugins/bbprb/bitbucket/ApiClient.java b/src/main/java/org/jenkinsci/plugins/bbprb/bitbucket/ApiClient.java
index 6f14010..721e038 100644
--- a/src/main/java/org/jenkinsci/plugins/bbprb/bitbucket/ApiClient.java
+++ b/src/main/java/org/jenkinsci/plugins/bbprb/bitbucket/ApiClient.java
@@ -37,7 +37,6 @@ public class ApiClient {
private static final String V2_API_BASE_URL =
"https://bitbucket.org/api/2.0/repositories/";
private static final String COMPUTED_KEY_FORMAT = "%s-%s";
- private String repository;
private Credentials credentials;
private String key;
private String name;
@@ -89,12 +88,9 @@ public class ApiClient {
}
}
- public <T extends HttpClientFactory> ApiClient(String username,
- String password,
- String repository, String key,
- String name) {
+ public <T extends HttpClientFactory>
+ ApiClient(String username, String password, String key, String name) {
this.credentials = new UsernamePasswordCredentials(username, password);
- this.repository = repository;
this.key = key;
this.name = name;
this.factory = HttpClientFactory.INSTANCE;
@@ -136,9 +132,10 @@ public class ApiClient {
return this.computeAPIKey(bsKey);
}
- public void setBuildStatus(String revision, BuildState state, String buildUrl,
- String comment, String keyEx) {
- String url = v2("/commit/" + revision + "/statuses/build");
+ public void setBuildStatus(String repository, String revision,
+ BuildState state, String buildUrl, String comment,
+ String keyEx) {
+ String url = v2(repository + "/commit/" + revision + "/statuses/build");
String computedKey = this.computeAPIKey(keyEx);
NameValuePair[] data = new NameValuePair[] {
new NameValuePair("description", comment),
@@ -157,7 +154,7 @@ public class ApiClient {
}
private String v2(String path) {
- return V2_API_BASE_URL + this.repository + path;
+ return V2_API_BASE_URL + path;
}
private String post(String path, NameValuePair[] data) {