Search in sources :

Example 1 with VcsRootEntry

use of jetbrains.buildServer.vcs.VcsRootEntry 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 2 with VcsRootEntry

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

the class MapFullPathTest method bulk.

public void bulk() throws Exception {
    // clone repository for myRoot and root3
    RepositoryStateData state0 = RepositoryStateData.createSingleVersionState("a7274ca8e024d98c7d59874f19f21d26ee31d41d");
    RepositoryStateData state1 = myGit.getCurrentState(myRoot);
    myGit.getCollectChangesPolicy().collectChanges(myRoot, state0, state1, CheckoutRules.DEFAULT);
    // tracks same repo as myRoot1
    VcsRoot root3 = vcsRoot().withId(3).withFetchUrl(myRemoteRepositoryDir.getAbsolutePath()).build();
    // tracks same repo as myRoot2
    VcsRoot root4 = vcsRoot().withId(4).withFetchUrl(myRemoteRepositoryDir2.getAbsolutePath()).build();
    List<Boolean> result = myGit.checkSuitable(asList(new VcsRootEntry(myRoot, new CheckoutRules("-:dir1")), new VcsRootEntry(myRoot, new CheckoutRules("+:dir1")), new VcsRootEntry(myRoot, new CheckoutRules("+:dir2")), new VcsRootEntry(myRoot2, new CheckoutRules("+:dir2")), new VcsRootEntry(root3, new CheckoutRules("+:dir1")), new VcsRootEntry(root4, new CheckoutRules("+:dir4")), new VcsRootEntry(root3, new CheckoutRules("+:dir5")), new VcsRootEntry(root4, new CheckoutRules("+:dir6"))), asList(// affects root and root3
    "a7274ca8e024d98c7d59874f19f21d26ee31d41d-add81050184d3c818560bdd8839f50024c188586||dir1/text1.txt", // affects no repo
    "abababababababababababababababababababab||."));
    then(result).containsExactly(false, true, false, false, true, false, false, false);
}
Also used : RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRootEntry(jetbrains.buildServer.vcs.VcsRootEntry) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 3 with VcsRootEntry

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

the class MapFullPathTest method setUp.

@BeforeMethod
public void setUp() throws IOException {
    new TeamCityProperties() {

        {
            setModel(new BasePropertiesModel() {
            });
        }
    };
    myTempFiles = new TempFiles();
    myContext = new Mockery() {

        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
    };
    myRemoteRepositoryDir = myTempFiles.createTempDir();
    copyRepository(dataFile("repo_for_fetch.1"), myRemoteRepositoryDir);
    myRemoteRepositoryDir2 = myTempFiles.createTempDir();
    copyRepository(dataFile("repo.git"), myRemoteRepositoryDir2);
    ServerPaths paths = new ServerPaths(myTempFiles.createTempDir().getAbsolutePath());
    GitSupportBuilder gitBuilder = gitSupport().withServerPaths(paths);
    myGit = gitBuilder.build();
    myMapFullPath = gitBuilder.getMapFullPath();
    myRoot = vcsRoot().withId(1).withFetchUrl(myRemoteRepositoryDir.getAbsolutePath()).build();
    myRootEntry = new VcsRootEntry(myRoot, CheckoutRules.DEFAULT);
    myRoot2 = vcsRoot().withId(2).withFetchUrl(myRemoteRepositoryDir2.getAbsolutePath()).build();
    myRootEntry2 = new VcsRootEntry(myRoot2, CheckoutRules.DEFAULT);
}
Also used : BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) VcsRootEntry(jetbrains.buildServer.vcs.VcsRootEntry) Mockery(org.jmock.Mockery) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) TempFiles(jetbrains.buildServer.TempFiles)

Aggregations

VcsRootEntry (jetbrains.buildServer.vcs.VcsRootEntry)3 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)2 TempFiles (jetbrains.buildServer.TempFiles)1 GitVcsRoot (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsRoot)1 BasePropertiesModel (jetbrains.buildServer.serverSide.BasePropertiesModel)1 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)1 TeamCityProperties (jetbrains.buildServer.serverSide.TeamCityProperties)1 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)1 RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 Mockery (org.jmock.Mockery)1