Search in sources :

Example 11 with VcsRoot

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

the class AuthSettingsTest method auth_uri_for_anonymous_protocol_should_not_have_user_and_password.

@TestFor(issues = "TW-25087")
public void auth_uri_for_anonymous_protocol_should_not_have_user_and_password() throws Exception {
    VcsRoot root = vcsRoot().withFetchUrl("git://some.org/repo.git").withAuthMethod(AuthenticationMethod.PASSWORD).withUsername("user").withPassword("pwd").build();
    AuthSettings authSettings = new AuthSettingsImpl(root, new URIishHelperImpl());
    URIish authURI = new URIishHelperImpl().createAuthURI(authSettings, "git://some.org/repo.git").get();
    assertNull(authURI.getUser());
    assertNull(authURI.getPass());
}
Also used : URIish(org.eclipse.jgit.transport.URIish) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) TestFor(jetbrains.buildServer.util.TestFor)

Example 12 with VcsRoot

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

the class SGitVcsRoot method getOrRefreshToken.

@Nullable
protected ExpiringAccessToken getOrRefreshToken(@NotNull String tokenId) {
    VcsRoot vcsRoot = getOriginalRoot();
    if (myTokenRefresher == null)
        return null;
    SVcsRoot parentRoot = vcsRoot instanceof SVcsRoot ? (SVcsRoot) vcsRoot : vcsRoot instanceof VcsRootInstance ? ((VcsRootInstance) vcsRoot).getParent() : null;
    if (parentRoot == null) {
        return myTokenRefresher.getRefreshableToken(vcsRoot.getExternalId(), tokenId);
    } else {
        return myTokenRefresher.getRefreshableToken(parentRoot.getProject(), tokenId);
    }
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot 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;
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) VcsRootEntry(jetbrains.buildServer.vcs.VcsRootEntry) GitVcsRoot(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) GitVcsRoot(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot)

Example 14 with VcsRoot

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

the class ScriptGenTest method check_escaping.

@TestFor(issues = "TW-40688")
@Test(dataProvider = "passwords")
public void check_escaping(@NotNull String password) throws Exception {
    VcsRoot root = createRootWithPassword(password);
    GeneralCommandLine cmd = new GeneralCommandLine();
    cmd.setExePath(createGenerator().generateAskPass(new AuthSettingsImpl(root, new URIishHelperImpl())).getCanonicalPath());
    ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, null);
    assertEquals(password, trimNewLines(result.getStdout()));
}
Also used : AuthSettingsImpl(jetbrains.buildServer.buildTriggers.vcs.git.AuthSettingsImpl) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) URIishHelperImpl(jetbrains.buildServer.buildTriggers.vcs.git.agent.URIishHelperImpl) ExecResult(jetbrains.buildServer.ExecResult) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 15 with VcsRoot

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

the class SubmoduleErrorsTest method cannot_fetch_submodule.

public void cannot_fetch_submodule() throws Exception {
    String submodulePath = "sub";
    String wrongSubmoduleUrl = new File(myMainRepo.getParent(), "sub2").getCanonicalPath();
    String brokenCommit = "9c328ea69b41ad2bfa162c72fd52cf87376225b7";
    VcsRoot root = vcsRoot().withFetchUrl(myMainRepoUrl).withSubmodulePolicy(SubmodulesCheckoutPolicy.CHECKOUT).build();
    try {
        myGitSupport.collectChanges(root, "6dbc05799659295e480894e367f4159d57fba30d", brokenCommit, CheckoutRules.DEFAULT);
        fail("Should fail due to incorrect submodule url");
    } catch (VcsException e) {
        String msg = e.getMessage();
        assertTrue(msg.contains("Cannot fetch the '" + wrongSubmoduleUrl + "' repository used as a submodule at the '" + submodulePath + "' path in the '" + myMainRepoUrl + "' repository in the " + brokenCommit + " commit"));
    }
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File)

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