in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/space/SpaceSettings.java [351:393]
private SpaceConnectDescriber guessConnectionFromFetchUrl(@NotNull SBuildType buildType, @NotNull SVcsRoot vcsRoot, boolean checkPublishingCapability) {
final String fetchUrl = vcsRoot.getProperty("url");
if (StringUtil.isEmptyOrSpaces(fetchUrl)) {
debugLogUnconditionalPublishingInfo(buildType, () -> "VCS root " + LogUtil.describe(vcsRoot) + " can't be used: the fetch URL is empty");
return null;
}
final TokenizedFetchUrl tokenizedFetchUrl;
try {
tokenizedFetchUrl = tokenizeFetchUrl(fetchUrl);
} catch (InvalidUriException e) {
debugLogUnconditionalPublishingInfo(buildType,
() -> "VCS root " + LogUtil.describe(vcsRoot) + " can't be used: failed to extract project key out of fetch URL " + fetchUrl,
e);
return null;
}
if (tokenizedFetchUrl.getProjectKey() == null) {
debugLogUnconditionalPublishingInfo(buildType, () -> "VCS root " + LogUtil.describe(vcsRoot) + " can't be used: unable to locate project key in fetch URL " + fetchUrl);
return null;
}
final String projectKey = tokenizedFetchUrl.getProjectKey().toUpperCase(Locale.ROOT);
final List<OAuthConnectionDescriptor> potentialConnections = myOAuthConnectionManager.getAvailableConnectionsOfType(buildType.getProject(), SpaceOAuthProvider.TYPE);
for (OAuthConnectionDescriptor potentialConnection : potentialConnections) {
final SpaceConnectDescriber spaceConnection = new SpaceConnectDescriber(potentialConnection);
if (!matchesUrl(buildType, potentialConnection, spaceConnection, tokenizedFetchUrl)) {
continue;
}
if (!checkPublishingCapability) {
return spaceConnection;
}
final SpaceApplicationInformation applicationInfo = myApplicationInformationManager.getForConnection(spaceConnection);
if (hasPublishStatusRights(buildType, potentialConnection, applicationInfo, projectKey)) {
return spaceConnection;
}
}
debugLogUnconditionalPublishingInfo(buildType, () -> "VCS root " + LogUtil.describe(vcsRoot) + " can't be used: there is no usable connection for project key " + projectKey);
return null;
}