Search in sources :

Example 6 with VcsRoot

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

the class AutoCheckoutTest method git_version_does_not_support_sparse_checkout_default_rules.

public void git_version_does_not_support_sparse_checkout_default_rules() throws IOException, VcsException {
    GitVersion gitVersion = GIT_WITH_SPARSE_CHECKOUT.previousVersion();
    myVcsSupport = vcsSupportWithFakeGitOfVersion(gitVersion);
    VcsRoot vcsRoot = vcsRootWithAgentGitPath(gitVersion.toString());
    AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).build();
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, build);
    then(canCheckout.getCanNotCheckoutReason()).isNull();
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 7 with VcsRoot

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

the class AutoCheckoutTest method should_check_auth_method.

public void should_check_auth_method() throws Exception {
    myVcsSupport = vcsSupportWithRealGit();
    VcsRoot vcsRoot = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withAuthMethod(AuthenticationMethod.PRIVATE_KEY_FILE).withAgentGitPath(getGitPath()).build();
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, runningBuild().addRoot(vcsRoot).build());
    then(canCheckout.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.UNKNOWN_REASON_TYPE);
    then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("TeamCity doesn't support authentication method 'Private Key' with agent checkout. Please use different authentication method.");
}
Also used : AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 8 with VcsRoot

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

the class AutoCheckoutTest method exclude_rules_are_used_without_sparse_checkout.

public void exclude_rules_are_used_without_sparse_checkout() throws IOException, VcsException {
    myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_WITH_SPARSE_CHECKOUT);
    VcsRoot vcsRoot = vcsRootWithAgentGitPath();
    AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "false").addRootEntry(vcsRoot, "-:dir/q.txt").build();
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules("-:dir/q.txt"), build);
    then(canCheckout.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES);
    then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot perform sparse checkout using git " + GIT_WITH_SPARSE_CHECKOUT);
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 9 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot 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 10 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot 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)

Aggregations

VcsRoot (jetbrains.buildServer.vcs.VcsRoot)59 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)25 TestFor (jetbrains.buildServer.util.TestFor)17 Test (org.testng.annotations.Test)16 GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)15 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)10 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)9 File (java.io.File)8 VcsException (jetbrains.buildServer.vcs.VcsException)8 URIish (org.eclipse.jgit.transport.URIish)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)3 NotNull (org.jetbrains.annotations.NotNull)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)2 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)2 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)2 TeamCitySshKey (jetbrains.buildServer.ssh.TeamCitySshKey)2 BulkPatchBuilder (jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder)2 RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)2