diff --git a/README.md b/README.md index 1091fa8..25ef60f 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ Parameter: | `buildKey` | String | yes | The unique key identifying the current build phase | `buildName` | String | yes | The build phase's name shown on BitBucket | `buildDescription` | String | yes | The build phase's description shown on BitBucket +| `buildUrl` | String | yes | The url linked to the phase in BitBucket. To link to a Jenkins artifact use `"${BUILD_URL}artifact/example.txt"` | `repoSlug`| String | yes | The slug of the bitbucket repository to send the notification to | `commitId` | String | yes | The id of the commit to attach the status notification to diff --git a/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifierStep.java b/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifierStep.java index 62f5c71..e58a69f 100644 --- a/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifierStep.java +++ b/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifierStep.java @@ -77,6 +77,12 @@ public class BitbucketBuildStatusNotifierStep extends AbstractStepImpl { this.buildDescription = buildDescription; } + private String buildUrl; + public String getBuildUrl() { return this.buildUrl; } + @DataBoundSetter public void setBuildUrl(String buildUrl) { + this.buildUrl = buildUrl; + } + private String buildState; public String getBuildState() { return this.buildState; } @@ -194,7 +200,10 @@ public Void run() throws Exception { logger.info("Got commit id " + commitId); logger.info("Got repo slug = " + repoSlug); - String buildUrl = BitbucketBuildStatusHelper.buildUrlFromBuild(build); + String buildUrl = step.getBuildUrl(); + if (buildUrl == null) { + buildUrl = BitbucketBuildStatusHelper.buildUrlFromBuild(build); + } BitbucketBuildStatus buildStatus = new BitbucketBuildStatus(buildState, buildKey, buildUrl, buildName, buildDescription);