import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
+import org.sonar.db.alm.setting.ALM;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.server.component.ComponentFinder;
public class ListAction implements AlmSettingsWsAction {
private static final String PARAM_PROJECT = "project";
+ private static final String BITBUCKETCLOUD_ROOT_URL = "https://bitbucket.org/";
private final DbClient dbClient;
private final UserSession userSession;
AlmSetting.Builder almSettingBuilder = AlmSetting.newBuilder()
.setKey(almSetting.getKey())
.setAlm(AlmSettingsSupport.toAlmWs(almSetting.getAlm()));
- ofNullable(almSetting.getUrl()).ifPresent(almSettingBuilder::setUrl);
+
+ if (almSetting.getAlm() == ALM.BITBUCKET_CLOUD) {
+ almSettingBuilder.setUrl(BITBUCKETCLOUD_ROOT_URL + almSetting.getAppId() + "/");
+ } else {
+ ofNullable(almSetting.getUrl()).ifPresent(almSettingBuilder::setUrl);
+ }
+
return almSettingBuilder.build();
})
.collect(Collectors.toList());
tuple(AlmSettings.Alm.gitlab, gitlabAlmSetting.getKey(), true, gitlabAlmSetting.getUrl()),
tuple(AlmSettings.Alm.gitlab, gitlabAlmSettingWithoutUrl.getKey(), false, ""),
tuple(AlmSettings.Alm.bitbucket, bitbucketAlmSetting.getKey(), true, bitbucketAlmSetting.getUrl()),
- tuple(AlmSettings.Alm.bitbucketcloud, bitbucketCloudAlmSetting.getKey(), false, ""));
+ tuple(AlmSettings.Alm.bitbucketcloud, bitbucketCloudAlmSetting.getKey(), true,
+ "https://bitbucket.org/" + bitbucketCloudAlmSetting.getAppId() + "/"));
}
@Test
db.almSettings().insertBitbucketCloudAlmSetting(
almSettingDto -> almSettingDto
.setKey("Bitbucket Cloud - Dev Team")
- .setUrl("https://bitbucket.org"));
+ .setAppId("workspace"));
db.almSettings().insertGitlabAlmSetting(
almSettingDto -> almSettingDto
.setKey("GitLab - Dev Team")
{
"key": "Bitbucket Cloud - Dev Team",
"alm": "bitbucketcloud",
- "url": "https://bitbucket.org"
+ "url": "https://bitbucket.org/workspace/"
},
{
"key": "GitLab - Dev Team",