Search in sources :

Example 1 with VcsRoot

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

the class FetchCommandImpl method getTeamCityPrivateKey.

private File getTeamCityPrivateKey(@NotNull AuthSettings authSettings) throws VcsException {
    if (authSettings.getAuthMethod() != AuthenticationMethod.TEAMCITY_SSH_KEY)
        return null;
    String keyId = authSettings.getTeamCitySshKeyId();
    if (keyId == null)
        return null;
    VcsRoot root = authSettings.getRoot();
    if (root == null)
        return null;
    TeamCitySshKey privateKey = mySshKeyManager.getKey(root);
    if (privateKey == null)
        return null;
    try {
        File privateKeyFile = FileUtil.createTempFile("private", "key");
        FileUtil.writeToFile(privateKeyFile, privateKey.getPrivateKey());
        return privateKeyFile;
    } catch (IOException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) IOException(java.io.IOException) TeamCitySshKey(jetbrains.buildServer.ssh.TeamCitySshKey) File(java.io.File)

Example 2 with VcsRoot

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

the class AuthSettingsTest method credential_provider_should_return_true_when_all_items_provided.

public void credential_provider_should_return_true_when_all_items_provided() throws Exception {
    VcsRoot root = vcsRoot().withFetchUrl("http://some.org/repository").withAuthMethod(AuthenticationMethod.PASSWORD).withUsername("user").build();
    CredentialsProvider c = new AuthCredentialsProvider(new AuthSettingsImpl(root, new URIishHelperImpl()));
    assertFalse(c.supports(new CredentialItem.Username(), new CredentialItem.Password()));
    final URIish uri = new URIish("http://some.org/repository");
    assertTrue(c.get(uri, new CredentialItem.Username()));
    assertFalse(c.get(uri, new CredentialItem.Password()));
    assertFalse(c.get(uri, new CredentialItem.Username(), new CredentialItem.Password()));
}
Also used : URIish(org.eclipse.jgit.transport.URIish) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider)

Example 3 with VcsRoot

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

the class AutoCheckoutTest method git_client_found_by_path_from_root.

public void git_client_found_by_path_from_root() throws IOException, VcsException {
    myVcsSupport = vcsSupportWithRealGit();
    VcsRoot vcsRoot = vcsRootWithAgentGitPath();
    verifyCanCheckout(vcsRoot, CheckoutRules.DEFAULT, runningBuild().addRoot(vcsRoot).withAgentConfiguration(myAgentConfiguration).build());
}
Also used : VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 4 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.

public void git_version_does_not_support_sparse_checkout() throws IOException, VcsException {
    GitVersion gitVersion = GIT_WITH_SPARSE_CHECKOUT.previousVersion();
    myVcsSupport = vcsSupportWithFakeGitOfVersion(gitVersion);
    VcsRoot vcsRoot = vcsRootWithAgentGitPath(getGitPath());
    AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").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 " + gitVersion);
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 5 with VcsRoot

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

the class AutoCheckoutTest method git_client_not_found_by_path_from_root.

public void git_client_not_found_by_path_from_root() throws IOException {
    myVcsSupport = vcsSupportWithRealGit();
    VcsRoot vcsRoot = vcsRootWithAgentGitPath("gitt");
    AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, runningBuild().addRoot(vcsRoot).build());
    then(canCheckout.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NO_VCS_CLIENT);
    then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Unable to run git at path gitt");
}
Also used : AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) 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