Skip to content

Commit 53b3dfb

Browse files
authored
[JENKINS-75440] OrganizationFolder does not show Bitbucket DC project avatar (#1009)
Fix wrong avatar URL in BitbucketServerProject
1 parent 60555a8 commit 53b3dfb

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Support to run Server under Windows has been dismissed since version 7.14+
9696
### Run inside docker
9797

9898
1. run `docker pull nolddor/atlassian-sdk:17-jdk`
99-
2. run `docker run -it -p 7990:7990 -p 7999:7999 nolddor/atlassian-sdk:17-jdk`
99+
2. run `docker run -it -p 7990:7990 -p 7999:7999 -v %USER%\.m2:/root/.m2 nolddor/atlassian-sdk:17-jdk`
100100
3. Inside the container:
101101
- install git with `apk add git`
102-
- run `/opt/atlassian-plugin-sdk/bin/atlas-run-standalone --product bitbucket`
102+
- run `/opt/atlassian-plugin-sdk/bin/atlas-run-standalone --product bitbucket --version 9.5.2`

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration;
3636
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint;
3737
import com.cloudbees.jenkins.plugins.bitbucket.impl.avatars.BitbucketTeamAvatarMetadataAction;
38+
import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils;
3839
import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketCredentials;
3940
import com.cloudbees.jenkins.plugins.bitbucket.impl.util.MirrorListSupplier;
4041
import com.cloudbees.jenkins.plugins.bitbucket.server.BitbucketServerWebhookImplementation;
@@ -579,7 +580,7 @@ public List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner,
579580
if (showAvatar()) {
580581
avatarURL = team.getAvatar();
581582
}
582-
teamURL = team.getLink("html");
583+
teamURL = BitbucketApiUtils.isCloud(client) ? team.getLink("html") : team.getLink("self");
583584
teamDisplayName = StringUtils.defaultIfBlank(team.getDisplayName(), team.getName());
584585
if (StringUtils.isNotBlank(teamURL)) {
585586
if (team instanceof BitbucketCloudWorkspace wks) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public Map<String, List<BitbucketHref>> getLinks() {
5959

6060
@Override
6161
public String getAvatar() {
62-
return getLink("self") + "/avatar.png";
62+
String baseURL = getLink("self").replace("/projects", "/rest/api/1.0/projects");
63+
return baseURL + "/avatar.png";
6364
}
6465
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketBuildStatus;
2929
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketBuildStatus.Status;
3030
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
31+
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketTeam;
3132
import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketIntegrationClientFactory;
3233
import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketIntegrationClientFactory.BitbucketServerIntegrationClient;
3334
import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketIntegrationClientFactory.IRequestAudit;
@@ -237,6 +238,16 @@ void verify_getTag_request_URL() throws Exception {
237238
.hasPath("/rest/api/1.0/projects/amuniz/repos/test-repos/tags/v0.0.0"));
238239
}
239240

241+
@Issue("JENKINS-75440")
242+
@Test
243+
void verify_avatar_URL() throws Exception {
244+
String serverURL = "http://localhost:7990/bitbucket";
245+
BitbucketServerAPIClient client = (BitbucketServerAPIClient) BitbucketIntegrationClientFactory.getClient(serverURL, "amuniz", "test-repos");
246+
247+
BitbucketTeam project = client.getTeam();
248+
assertThat(project.getAvatar()).isEqualTo("http://localhost:7990/bitbucket/rest/api/1.0/projects/amuniz/avatar.png");
249+
}
250+
240251
@Issue("JENKINS-75119")
241252
@Test
242253
void verify_HttpHost_built_when_server_has_context_root() throws Exception {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"key": "amuniz",
3+
"id": 1,
4+
"name": "Project 1",
5+
"description": "Default configuration project #1",
6+
"public": false,
7+
"type": "NORMAL",
8+
"links": {
9+
"self": [
10+
{
11+
"href": "http://localhost:7990/bitbucket/projects/amuniz"
12+
}
13+
]
14+
}
15+
}

0 commit comments

Comments
 (0)