Skip to content

Commit aa728d3

Browse files
committed
[JENKINS-72780] The key value for the build notification is an UUID which couldn't be filter in required build feature of Bitbucket
Change the logic that trim the key at the end instead in the middle. Most important part of the path is the head
1 parent 5a91093 commit aa728d3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101

102102
import static java.util.Objects.requireNonNull;
103103
import static org.apache.commons.lang.StringUtils.abbreviate;
104+
import static org.apache.commons.lang.StringUtils.substring;
104105

105106
/**
106107
* Bitbucket API client.
@@ -499,7 +500,7 @@ public void postBuildStatus(@NonNull BitbucketBuildStatus status) throws IOExcep
499500

500501
String key = status.getKey();
501502
if (StringUtils.length(key) > 255) {
502-
newStatus.setKey(abbreviate(key, 255 - 33) + '/' + DigestUtils.md5Hex(key));
503+
newStatus.setKey(substring(key, 0, 255 - 33) + '/' + DigestUtils.md5Hex(key));
503504
}
504505

505506
String url = UriTemplate.fromTemplate(this.baseURL + API_COMMIT_STATUS_PATH)

src/test/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClientTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void verify_status_notitication_key_max_length() throws Exception {
118118
assertThatJson(json).node("key")
119119
.isString()
120120
.hasSize(255)
121+
.startsWith(longKey.substring(0, 255 - 33))
121122
.endsWith('/' + DigestUtils.md5Hex(longKey));
122123
}
123124
}

0 commit comments

Comments
 (0)