Skip to content

Commit af81ad8

Browse files
committed
New feature: override buildUrl
This allows the user of the plugin to set a different buildUrl. Bitbucket navigates to this Url when you click the buildName. The buildUrl will often be an artifact hosted by Jenkins. The user can concat this themselves from the BUILD_URL environment variable
1 parent c0959b1 commit af81ad8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Parameter:
163163
| `buildKey` | String | yes | The unique key identifying the current build phase
164164
| `buildName` | String | yes | The build phase's name shown on BitBucket
165165
| `buildDescription` | String | yes | The build phase's description shown on BitBucket
166+
| `buildUrl` | String | yes | The url linked to the phase in BitBucket. To link to a Jenkins artifact use `"${BUILD_URL}artifact/example.txt"`
166167
| `repoSlug`| String | yes | The slug of the bitbucket repository to send the notification to
167168
| `commitId` | String | yes | The id of the commit to attach the status notification to
168169

src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifierStep.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public class BitbucketBuildStatusNotifierStep extends AbstractStepImpl {
7777
this.buildDescription = buildDescription;
7878
}
7979

80+
private String buildUrl;
81+
public String getBuildUrl() { return this.buildUrl; }
82+
@DataBoundSetter public void setBuildUrl(String buildUrl) {
83+
this.buildUrl = buildUrl;
84+
}
85+
8086
private String buildState;
8187
public String getBuildState() { return this.buildState; }
8288

@@ -194,7 +200,10 @@ public Void run() throws Exception {
194200
logger.info("Got commit id " + commitId);
195201
logger.info("Got repo slug = " + repoSlug);
196202

197-
String buildUrl = BitbucketBuildStatusHelper.buildUrlFromBuild(build);
203+
String buildUrl = step.getBuildUrl();
204+
if (buildUrl == null) {
205+
buildUrl = BitbucketBuildStatusHelper.buildUrlFromBuild(build);
206+
}
198207

199208
BitbucketBuildStatus buildStatus = new BitbucketBuildStatus(buildState, buildKey, buildUrl, buildName,
200209
buildDescription);

0 commit comments

Comments
 (0)