in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/space/SpaceSettings.java [416:460]
private boolean matchesUrl(@NotNull SBuildType buildType,
@NotNull OAuthConnectionDescriptor connection,
@NotNull SpaceConnectDescriber spaceConnection,
@NotNull TokenizedFetchUrl tokenizedFetchUrl) {
final TokenizedServiceUrl tokenizedServiceUrl;
try {
tokenizedServiceUrl = tokenizeServiceUrl(spaceConnection.getFullAddress());
} catch (IllegalArgumentException e) {
debugLogUnconditionalPublishingInfo(buildType, () -> "Space connection " + LogUtil.describe(connection) + " can't be used: service URL is not parseable", e);
return false;
}
if (!Objects.equals(tokenizedServiceUrl.getOrganization(), tokenizedFetchUrl.getOrganization())) {
debugLogUnconditionalPublishingInfo(buildType, () -> "Space connection " + LogUtil.describe(connection) + " can't be used: organizations don't match, " +
tokenizedServiceUrl.getOrganization() + " (from service URL) != " + tokenizedFetchUrl.getOrganization() +
" (from fetch URL).");
return false;
}
if (tokenizedServiceUrl.getHost().equals(tokenizedServiceUrl.getHost())) {
debugLogUnconditionalPublishingInfo(buildType,
() -> "Space connection " + LogUtil.describe(connection) + " will be used: fetch URL and service URL indicate identical host.");
return true;
}
final String[] serviceHostTokens = tokenizedServiceUrl.getHost().split("\\.");
final String[] fetchHostTokens = tokenizedFetchUrl.getHost().split("\\.");
int matchCount = 0;
int i = serviceHostTokens.length - 1;
int j = fetchHostTokens.length - 1;
while (i >= 0 && j >= 0 && serviceHostTokens[i--].equals(fetchHostTokens[j--])) {
matchCount++;
}
if (matchCount <= 1) {
debugLogUnconditionalPublishingInfo(buildType, () -> "Space connection " + LogUtil.describe(connection) + " can't be used: hosts aren't similar enough, " +
tokenizedServiceUrl.getHost() + "(from service URL) vs " + tokenizedFetchUrl.getHost() + " (from fetch URL).");
return false;
}
debugLogUnconditionalPublishingInfo(buildType,
() -> "Space connection " + LogUtil.describe(connection) + " will be used: hosts are similar enough, " + tokenizedServiceUrl.getHost() +
"(from service URL) vs " + tokenizedFetchUrl.getHost() + " (from fetch URL).");
return true;
}