Search in sources :

Example 6 with AgentCheckoutAbility

use of jetbrains.buildServer.agent.vcs.AgentCheckoutAbility in project teamcity-git by JetBrains.

the class AutoCheckoutTest method should_respect_root_settings_when_checking_multi_root_constraints2.

@TestFor(issues = "TW-49786")
public void should_respect_root_settings_when_checking_multi_root_constraints2() throws Exception {
    VcsRoot root1 = vcsRoot().withId(1).withFetchUrl("http://some.org/repo1.git").build();
    VcsRoot root2 = vcsRoot().withId(2).withFetchUrl("http://some.org/repo2.git").build();
    AgentRunningBuild build = runningBuild().addRootEntry(root1, "+:dir1").addRootEntry(root2, "+:dir2").build();
    // both roots require sparse checkout and mapped into the same directory, but the second
    // root uses git version which doesn't support sparse checkout; we shouldn't take it into
    // account during canCheckout() check for the first root
    GitDetector detector = new GitDetector() {

        @NotNull
        public GitExec getGitPathAndVersion(@NotNull VcsRoot root, @NotNull BuildAgentConfiguration config, @NotNull AgentRunningBuild build) throws VcsException {
            if (root.equals(root1)) {
                return new GitExec("git1", GIT_WITH_SPARSE_CHECKOUT);
            }
            if (root.equals(root2)) {
                return new GitExec("git2", GIT_WITH_SPARSE_CHECKOUT.previousVersion());
            }
            throw new VcsException("Unexpected VCS root");
        }

        @NotNull
        @Override
        public GitExec getGitPathAndVersion(@NotNull AgentRunningBuild build) throws VcsException {
            throw new UnsupportedOperationException();
        }
    };
    myVcsSupport = createVcsSupport(detector);
    AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules("+:dir1"), build);
    AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules("+:dir2"), build);
    then(canCheckout1.getCanNotCheckoutReason()).isNull();
    then(canCheckout2.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES);
    then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Cannot perform sparse checkout using git " + GIT_WITH_SPARSE_CHECKOUT.previousVersion());
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) VcsException(jetbrains.buildServer.vcs.VcsException) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) GitDetector(jetbrains.buildServer.buildTriggers.vcs.git.agent.GitDetector) NotNull(org.jetbrains.annotations.NotNull) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) TestFor(jetbrains.buildServer.util.TestFor)

Example 7 with AgentCheckoutAbility

use of jetbrains.buildServer.agent.vcs.AgentCheckoutAbility in project teamcity-git by JetBrains.

the class AutoCheckoutTest method should_check_shared_paths_not_clashing.

public void should_check_shared_paths_not_clashing() throws Exception {
    myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_CLEAN_LEARNED_EXCLUDE);
    final VcsRoot vcsRoot = vcsRoot().withFetchUrl("/some/path").withAgentGitPath(getGitPath()).build();
    {
        final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), "some/path=>.").build();
        AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, build);
        then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
    }
    {
        final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), ".=>some/path").build();
        AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(".=>some/path"), build);
        then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
    }
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 8 with AgentCheckoutAbility

use of jetbrains.buildServer.agent.vcs.AgentCheckoutAbility in project teamcity-git by JetBrains.

the class AutoCheckoutTest method several_roots.

@TestFor(issues = "TW-49786")
@Test(dataProvider = "severalRootsSetups")
public void several_roots(@NotNull Setup setup) throws Exception {
    myVcsSupport = vcsSupportWithRealGit();
    VcsRoot root1 = vcsRoot().withId(1).withFetchUrl("http://some.org/repo1.git").withAgentGitPath(getGitPath()).build();
    VcsRoot root2 = vcsRoot().withId(2).withFetchUrl("http://some.org/repo2.git").withAgentGitPath(getGitPath()).build();
    AgentRunningBuild build = runningBuild().addRootEntry(root1, setup.getCheckoutRules1()).addRootEntry(root2, setup.getCheckoutRules2()).build();
    AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules(setup.getCheckoutRules1()), build);
    AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules(setup.getCheckoutRules2()), build);
    if (setup.isShouldFail()) {
        then(canCheckout1.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root '" + root1.getName() + "' into the same directory as VCS root '" + root2.getName() + "'");
        then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root '" + root2.getName() + "' into the same directory as VCS root '" + root1.getName() + "'");
    } else {
        then(canCheckout1.getCanNotCheckoutReason()).isNull();
        then(canCheckout2.getCanNotCheckoutReason()).isNull();
    }
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 9 with AgentCheckoutAbility

use of jetbrains.buildServer.agent.vcs.AgentCheckoutAbility in project teamcity-git by JetBrains.

the class AutoCheckoutTest method verifyCanCheckout.

private void verifyCanCheckout(final VcsRoot vcsRoot, CheckoutRules checkoutRules, final AgentRunningBuild build) throws VcsException {
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, checkoutRules, build);
    then(canCheckout.getCanNotCheckoutReason()).isNull();
    // do actual checkout and ensure that it completes without errors
    FileUtil.delete(myCheckoutDir);
    myCheckoutDir.mkdirs();
    myVcsSupport.updateSources(vcsRoot, checkoutRules, "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", myCheckoutDir, build, true);
    then(myCheckoutDir.listFiles()).isNotEmpty();
}
Also used : AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)

Example 10 with AgentCheckoutAbility

use of jetbrains.buildServer.agent.vcs.AgentCheckoutAbility in project teamcity-git by JetBrains.

the class AutoCheckoutTest method should_respect_root_settings_when_checking_multi_root_constraints.

@TestFor(issues = "TW-49786")
public void should_respect_root_settings_when_checking_multi_root_constraints() throws Exception {
    myVcsSupport = vcsSupportWithRealGit();
    // second root has broken git path, we should not take it into account
    // during canCheckout() for the first VCS root
    VcsRoot root1 = vcsRoot().withId(1).withAgentGitPath(getGitPath()).withFetchUrl("http://some.org/repo1.git").build();
    VcsRoot root2 = vcsRoot().withId(2).withAgentGitPath("wrongGitPath").withFetchUrl("http://some.org/repo2.git").build();
    AgentRunningBuild build = runningBuild().addRootEntry(root1, "+:dir1").addRootEntry(root2, "+:dir2").build();
    AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules("+:dir1"), build);
    AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules("+:dir2"), build);
    then(canCheckout1.getCanNotCheckoutReason()).isNull();
    then(canCheckout2.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NO_VCS_CLIENT);
    then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Unable to run git at path wrongGitPath");
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)11 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)10 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)8 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)7 TestFor (jetbrains.buildServer.util.TestFor)3 GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)2 BuildAgentConfiguration (jetbrains.buildServer.agent.BuildAgentConfiguration)1 GitDetector (jetbrains.buildServer.buildTriggers.vcs.git.agent.GitDetector)1 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.testng.annotations.Test)1