use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot in project teamcity-git by JetBrains.
the class GitAgentVcsSupport method canCheckout.
@NotNull
@Override
public AgentCheckoutAbility canCheckout(@NotNull final VcsRoot vcsRoot, @NotNull CheckoutRules checkoutRules, @NotNull final AgentRunningBuild build) {
AgentPluginConfig config;
try {
config = getAndCacheConfig(build, vcsRoot);
} catch (VcsException e) {
return AgentCheckoutAbility.noVcsClientOnAgent(e.getMessage());
}
Pair<CheckoutMode, String> pathAndMode = getTargetPathAndMode(checkoutRules);
String targetDir = pathAndMode.second;
if (targetDir == null) {
return AgentCheckoutAbility.notSupportedCheckoutRules("Unsupported rules for agent-side checkout: " + checkoutRules.getAsString());
}
if (pathAndMode.first == CheckoutMode.SPARSE_CHECKOUT && !canUseSparseCheckout(config)) {
return AgentCheckoutAbility.notSupportedCheckoutRules("Cannot perform sparse checkout using git " + config.getGitExec().getVersion());
}
try {
GitVcsRoot gitRoot = new GitVcsRoot(myMirrorManager, vcsRoot, new URIishHelperImpl());
UpdaterImpl.checkAuthMethodIsSupported(gitRoot, config);
} catch (VcsException e) {
return AgentCheckoutAbility.canNotCheckout(e.getMessage());
}
final List<VcsRootEntry> rootEntries = build.getVcsRootEntries();
if (rootEntries.size() > 1) {
for (VcsRootEntry entry : rootEntries) {
VcsRoot otherRoot = entry.getVcsRoot();
if (vcsRoot.equals(otherRoot))
continue;
if (isGitVcsRoot(entry)) {
AgentPluginConfig otherConfig;
try {
otherConfig = getAndCacheConfig(build, otherRoot);
} catch (VcsException e) {
// appropriate reason will be returned during otherRoot check
continue;
}
Pair<CheckoutMode, String> otherPathAndMode = getTargetPathAndMode(entry.getCheckoutRules());
if (otherPathAndMode.first == CheckoutMode.SPARSE_CHECKOUT && !canUseSparseCheckout(otherConfig)) {
// appropriate reason will be returned during otherRoot check
continue;
}
String entryPath = otherPathAndMode.second;
if (targetDir.equals(entryPath))
return AgentCheckoutAbility.canNotCheckout("Cannot checkout VCS root '" + vcsRoot.getName() + "' into the same directory as VCS root '" + otherRoot.getName() + "'");
} else if (CleanCommandUtil.isCleanEnabled(vcsRoot) && CleanCommandUtil.isClashingTargetPath(targetDir, entry, config.getGitVersion())) {
// in this case git clean command may remove files which belong to the other root
return AgentCheckoutAbility.canNotCheckout("Cannot checkout VCS root '" + vcsRoot.getName() + "' into the same directory as VCS root '" + otherRoot.getName() + "'");
}
}
}
return AgentCheckoutAbility.canCheckout();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot in project teamcity-git by JetBrains.
the class AgentMirrorCleaner method getRunningBuildRepositories.
private Set<String> getRunningBuildRepositories(@NotNull DirectoryCleanersProviderContext context) {
Set<String> repositories = new HashSet<String>();
for (VcsRootEntry entry : context.getRunningBuild().getVcsRootEntries()) {
VcsRoot root = entry.getVcsRoot();
if (!Constants.VCS_NAME.equals(root.getVcsName()))
continue;
try {
GitVcsRoot gitRoot = new AgentGitVcsRoot(myMirrorManager, root, myTokenStorage);
String repositoryUrl = gitRoot.getRepositoryFetchURL().toString();
LOG.debug("Repository " + repositoryUrl + " is used in the build, its mirror won't be cleaned");
addRepositoryWithSubmodules(repositories, gitRoot.getRepositoryFetchURL().toString());
} catch (VcsException e) {
LOG.warn("Error while creating git root " + root.getName() + ". If the root has a mirror on agent, the mirror might be cleaned", e);
}
}
return repositories;
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot in project teamcity-git by JetBrains.
the class HttpUrlWithUsernameTest method getMirrorConfig.
@NotNull
private StoredConfig getMirrorConfig(@NotNull VcsRootImpl root) throws IOException, VcsException {
GitVcsRoot gitRoot = new GitVcsRoot(myMirrorManager, root, new URIishHelperImpl());
File mirrorDir = myMirrorManager.getMirrorDir(gitRoot.getRepositoryFetchURL().toString());
Repository r = new RepositoryBuilder().setGitDir(mirrorDir).build();
return r.getConfig();
}
Aggregations