Search in sources :

Example 6 with GitVersion

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

the class SetUpstreamCommandImpl method call.

public void call() throws VcsException {
    GitCommandLine cmd = getCmd();
    GitVersion version = cmd.getGitVersion();
    if (version.isLessThan(new GitVersion(1, 7, 0))) {
        // ability to set upstream was added in 1.7.0
        return;
    } else if (version.isLessThan(new GitVersion(1, 8, 0))) {
        cmd.addParameters("branch", "--set-upstream", myLocalBranch, myUpstreamBranch);
    } else {
        cmd.addParameters("branch", "--set-upstream-to=" + myUpstreamBranch);
    }
    CommandUtil.runCommand(cmd.stdErrExpected(false));
}
Also used : GitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)

Example 7 with GitVersion

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

the class ListConfigCommandImpl method call.

@NotNull
@Override
public String call() throws VcsException {
    GitCommandLine cmd = getCmd();
    cmd.addParameters("config", "--list");
    if (!cmd.getGitVersion().isLessThan(new GitVersion(2, 8, 0))) {
        cmd.addParameter("--show-origin");
    }
    return CommandUtil.runCommand(cmd).getStdout().trim();
}
Also used : GitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with GitVersion

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

the class AgentStartupGitDetector method afterAgentConfigurationLoaded.

@Override
public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) {
    if (pathToGitConfigured(agent)) {
        LOG.debug("Path to git configured, will not try to detect git");
        return;
    }
    for (String path : getCandidatePaths()) {
        try {
            final GitVersion version = new AgentGitFacadeImpl(path).version().call();
            agent.getConfiguration().addEnvironmentVariable(Constants.TEAMCITY_AGENT_GIT_VERSION, version.toString());
            if (version.isSupported()) {
                LOG.info("Detect git at " + path);
                setPathToGit(agent, path);
                break;
            } else {
                LOG.debug("TeamCity supports Git version " + GitVersion.MIN + " or higher, git at " + path + " has version " + version + " and will not be used");
            }
        } catch (VcsException e) {
            LOG.debug("Cannot run git at " + path, e);
        }
    }
    detectGitLfs(agent);
    detectSSH(agent);
}
Also used : GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) VcsException(jetbrains.buildServer.vcs.VcsException)

Example 9 with GitVersion

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

the class GitDetectorImpl method getGitPathAndVersionInternal.

@NotNull
private GitExec getGitPathAndVersionInternal(@Nullable VcsRoot root, @Nullable BuildAgentConfiguration config, @NotNull AgentRunningBuild build) throws VcsException {
    String path = getPathFromRoot(root, config);
    if (path != null) {
        Loggers.VCS.info("Using vcs root's git: " + path);
    } else {
        path = build.getSharedBuildParameters().getEnvironmentVariables().get(Constants.TEAMCITY_AGENT_GIT_PATH);
        if (path != null) {
            Loggers.VCS.info("Using git specified by " + Constants.TEAMCITY_AGENT_GIT_PATH + ": " + path);
        } else {
            path = defaultGit();
            Loggers.VCS.info("Using default git: " + path);
        }
    }
    GitVersion version = getGitVersion(path);
    checkVersionIsSupported(path, version);
    return new GitExec(path, version, getCygwinBinPath(path));
}
Also used : GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with GitVersion

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

the class FetchCommandImpl method call.

public void call() throws VcsException {
    final GitCommandLine cmd = getCmd();
    final GitVersion gitVersion = cmd.getGitVersion();
    cmd.addParameter("fetch");
    if (myQuite)
        cmd.addParameter("-q");
    if (myShowProgress)
        cmd.addParameter("--progress");
    if (myDepth != null)
        cmd.addParameter("--depth=" + myDepth);
    if (!myFetchTags)
        cmd.addParameter("--no-tags");
    if (gitVersion.isGreaterThan(new GitVersion(1, 7, 3))) {
        // we process submodules separately
        cmd.addParameter("--recurse-submodules=no");
    }
    cmd.setHasProgress(true);
    if (myRefSpecs.size() > 1 && GitVersion.fetchSupportsStdin(gitVersion)) {
        cmd.addParameter("--stdin");
        cmd.addParameter(getRemote());
        runCmd(cmd.stdErrLogLevel("debug"), refSpecsToBytes(cmd));
    } else {
        cmd.addParameter(getRemote());
        myRefSpecs.forEach(refSpec -> cmd.addParameter(refSpec));
        runCmd(cmd.stdErrLogLevel("debug"));
    }
}
Also used : GitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandLine) GitVersion(jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)

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