Skip to content

Commit

Permalink
New feature: override buildUrl
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Erikvv committed Jan 31, 2020
1 parent 1a29bc9 commit 510ecff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 510ecff

Please sign in to comment.