in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/PublisherSettingsController.java [231:278]
private void testConnection(CommitStatusPublisherSettings settings, Map<String, String> params, @NotNull final HttpServletRequest request,
@NotNull ActionErrors errors) throws PublisherException {
BuildTypeIdentity buildTypeOrTemplate = getBuildTypeOrTemplate(request.getParameter("id"));
Map<String, String> resolvedProperties = resolveProperties(buildTypeOrTemplate, params);
String vcsRootId = resolvedProperties.get(Constants.VCS_ROOT_ID_PARAM);
if ((null == vcsRootId || vcsRootId.isEmpty())) {
List<SVcsRoot> roots = null;
if (buildTypeOrTemplate instanceof BuildTypeSettings) {
roots = ((BuildTypeSettings) buildTypeOrTemplate).getVcsRoots();
}
if (null == roots || roots.isEmpty()) {
throw new PublisherException("No VCS roots attached");
}
boolean isTested = false;
for (SVcsRoot sVcsRoot: roots) {
try {
VcsRoot vcsRoot = getResolvingVcsRoot(buildTypeOrTemplate, sVcsRoot);
if (settings.isPublishingForVcsRoot(vcsRoot)) {
isTested = true;
settings.testConnection(buildTypeOrTemplate, vcsRoot, resolvedProperties);
}
} catch (PublisherException ex) {
reportTestConnectionFailure(ex, errors);
}
}
if (!isTested) {
throw new PublisherException("No relevant VCS roots attached");
}
} else {
SVcsRoot sVcsRoot = myProjectManager.findVcsRootByExternalId(vcsRootId);
if (null == sVcsRoot) {
try {
Long internalId = Long.valueOf(vcsRootId);
sVcsRoot = myProjectManager.findVcsRootById(internalId);
} catch (NumberFormatException ex) {
throw new PublisherException(String.format("Unknown VCS root id '%s'", vcsRootId));
}
}
if (null == sVcsRoot) {
throw new PublisherException(String.format("VCS root not found for id '%s'", vcsRootId));
}
VcsRoot vcsRoot = getResolvingVcsRoot(buildTypeOrTemplate, sVcsRoot);
settings.testConnection(buildTypeOrTemplate, vcsRoot, resolvedProperties);
}
}