Search in sources :

Example 1 with GitVersion

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

the class GitAgentVersionHealthReport method report.

@Override
public void report(@NotNull final HealthStatusScope scope, @NotNull final HealthStatusItemConsumer consumer) {
    final List<BuildAgentEx> unsupported = new ArrayList<>();
    final List<BuildAgentEx> deprecated = new ArrayList<>();
    for (BuildAgentEx a : myAgentManager.getRegisteredAgents()) {
        final GitVersion version = getGitVersion(a);
        if (version == null) {
            LOG.debug("No git executable version reported for \"" + a.getName() + "\" agent via \"" + Constants.TEAMCITY_AGENT_GIT_VERSION + "\" environment property");
            continue;
        }
        if (version.isLessThan(GitVersion.MIN)) {
            unsupported.add(a);
        } else if (version.isLessThan(myDeprecatedVersion)) {
            deprecated.add(a);
        }
    }
    if (!unsupported.isEmpty()) {
        final Map<String, Object> model = new HashMap<>();
        model.put("gitVersionUnsupported", true);
        model.put("gitVersionAgentCount", unsupported.size());
        model.put("gitVersionAgents", groupAgents(unsupported));
        model.put("hasSeveralPools", myAgentPoolManager.hasSeveralPools());
        consumer.consumeGlobal(new HealthStatusItem(UNSUPPORTED_CATEGORY, myUnsupportedCategory, model));
    }
    if (!deprecated.isEmpty()) {
        final Map<String, Object> model = new HashMap<>();
        model.put("gitVersionUnsupported", false);
        model.put("gitVersionAgentCount", deprecated.size());
        model.put("gitVersionAgents", groupAgents(deprecated));
        model.put("hasSeveralPools", myAgentPoolManager.hasSeveralPools());
        consumer.consumeGlobal(new HealthStatusItem(DEPRECATED_CATEGORY, myDeprecatedCategory, model));
    }
}
Also used : GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) BuildAgentEx(jetbrains.buildServer.serverSide.BuildAgentEx)

Example 2 with GitVersion

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion 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 3 with GitVersion

use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion 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 4 with GitVersion

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

the class FetchCommandImplTest method negative_refspec_for_tags.

@Test
public void negative_refspec_for_tags() throws Exception {
    final String gitPath = getGitPath();
    final GitVersion version = new AgentGitFacadeImpl(gitPath).version().call();
    if (!GitVersion.negativeRefSpecSupported(version))
        throw new SkipException("Git version is too old to run this test");
    final File remote = GitTestUtil.dataFile("fetch_multiple_refspecs");
    new File(remote, "refs" + File.separator + "heads").mkdirs();
    final File work = createTempDir();
    runCommand(false, gitPath, work, "init", "--bare");
    final StringBuilder log = new StringBuilder();
    final StubContext context = new StubContext("git", version);
    context.setLogger(createLogger(log));
    final GitCommandLine cmd = new GitCommandLine(context, getFakeGen());
    cmd.setExePath(gitPath);
    cmd.setWorkingDirectory(work);
    final FetchCommandImpl fetch = new FetchCommandImpl(cmd);
    fetch.setRemote(remote.getAbsolutePath());
    fetch.setAuthSettings(getEmptyAuthSettings());
    fetch.setRefspec("+refs/*:refs/*");
    fetch.setRefspec("^refs/tags/*");
    fetch.setFetchTags(false);
    fetch.call();
    // master + 6000 branches
    assertEquals(6001, FileUtil.listFiles(new File(work, "refs/heads"), (d, n) -> true).length);
    assertFalse(new File(work, "refs/tags/my_tag").exists());
    final String logStr = log.toString();
    assertFalse(logStr.contains("my_tag"));
}
Also used : AgentGitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitCommandLine) GitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine) AgentGitFacadeImpl(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitFacadeImpl) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) FetchCommandImpl(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl) StubContext(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.StubContext) SkipException(org.testng.SkipException) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with GitVersion

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

the class FetchCommandImplTest method fetch_multiple_refspecs.

@Test
public void fetch_multiple_refspecs() throws Exception {
    final String gitPath = getGitPath();
    final GitVersion version = new AgentGitFacadeImpl(gitPath).version().call();
    if (!GitVersion.fetchSupportsStdin(version))
        throw new SkipException("Git version is too old to run this test");
    final File remote = GitTestUtil.dataFile("fetch_multiple_refspecs");
    new File(remote, "refs" + File.separator + "heads").mkdirs();
    final File work = createTempDir();
    runCommand(false, gitPath, work, "init");
    final GitCommandLine cmd = new GitCommandLine(new StubContext("git", version), getFakeGen());
    cmd.setExePath(gitPath);
    cmd.setWorkingDirectory(work);
    final FetchCommandImpl fetch = new FetchCommandImpl(cmd);
    fetch.setRemote(remote.getAbsolutePath());
    fetch.setAuthSettings(getEmptyAuthSettings());
    for (int i = 0; i < 6000; ++i) {
        fetch.setRefspec("+refs/heads/branch" + i + ":refs/remotes/origin/branch" + i);
    }
    fetch.call();
    assertEquals(6000, FileUtil.listFiles(new File(work, ".git/refs/remotes/origin"), (d, n) -> true).length);
}
Also used : AgentGitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitCommandLine) GitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine) AgentGitFacadeImpl(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitFacadeImpl) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) FetchCommandImpl(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl) StubContext(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.StubContext) SkipException(org.testng.SkipException) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)11 GitCommandLine (jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine)5 AgentGitFacadeImpl (jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitFacadeImpl)3 File (java.io.File)2 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)2 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)2 AgentGitCommandLine (jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitCommandLine)2 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)2 FetchCommandImpl (jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl)2 StubContext (jetbrains.buildServer.buildTriggers.vcs.git.command.impl.StubContext)2 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)2 NotNull (org.jetbrains.annotations.NotNull)2 SkipException (org.testng.SkipException)2 Test (org.testng.annotations.Test)2 BuildAgentEx (jetbrains.buildServer.serverSide.BuildAgentEx)1 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 DataProvider (org.testng.annotations.DataProvider)1