|
96 | 96 | import java.util.logging.Logger;
|
97 | 97 | import jenkins.authentication.tokens.api.AuthenticationTokens;
|
98 | 98 | import jenkins.model.Jenkins;
|
| 99 | +import jenkins.plugins.git.GitTagSCMHead; |
99 | 100 | import jenkins.plugins.git.traits.GitBrowserSCMSourceTrait;
|
100 | 101 | import jenkins.scm.api.SCMHead;
|
101 | 102 | import jenkins.scm.api.SCMHeadCategory;
|
@@ -1135,15 +1136,24 @@ protected List<Action> retrieveActions(@NonNull SCMHead head,
|
1135 | 1136 | List<Action> result = new ArrayList<>();
|
1136 | 1137 | UriTemplate template;
|
1137 | 1138 | String title = null;
|
1138 |
| - if (BitbucketCloudEndpoint.SERVER_URL.equals(getServerUrl())) { |
1139 |
| - template = UriTemplate.fromTemplate(getServerUrl() + CLOUD_REPO_TEMPLATE + "/{branchOrPR}/{prIdOrHead}") |
1140 |
| - .set("owner", repoOwner) |
1141 |
| - .set("repo", repository); |
| 1139 | + if (BitbucketApiUtils.isCloud(getServerUrl())) { |
| 1140 | + String resourceName; |
| 1141 | + String resourceId; |
1142 | 1142 | if (head instanceof PullRequestSCMHead prHead) {
|
1143 |
| - template.set("branchOrPR", "pull-requests").set("prIdOrHead", prHead.getId()); |
| 1143 | + resourceName = "pull-requests"; |
| 1144 | + resourceId = prHead.getId(); |
| 1145 | + } else if (head instanceof GitTagSCMHead) { |
| 1146 | + resourceName = "commits"; |
| 1147 | + resourceId = head.getName(); |
1144 | 1148 | } else {
|
1145 |
| - template.set("branchOrPR", "branch").set("prIdOrHead", head.getName()); |
| 1149 | + resourceName = "branch"; |
| 1150 | + resourceId = head.getName(); |
1146 | 1151 | }
|
| 1152 | + template = UriTemplate.fromTemplate(getServerUrl() + CLOUD_REPO_TEMPLATE + "/{resourceName}/{resourceId}") |
| 1153 | + .set("owner", repoOwner) |
| 1154 | + .set("repo", repository) |
| 1155 | + .set("resourceName", resourceName) |
| 1156 | + .set("resourceId", resourceId); |
1147 | 1157 | } else {
|
1148 | 1158 | if (head instanceof PullRequestSCMHead prHead) {
|
1149 | 1159 | template = UriTemplate
|
|
0 commit comments