Search in sources :

Example 56 with VcsException

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

the class AgentGitFacadeImpl method resolvePath.

@NotNull
public String resolvePath(@NotNull File f) throws VcsException {
    try {
        final GitExec gitExec = getCtx().getGitExec();
        if (gitExec.isCygwin()) {
            String cygwinBin = gitExec.getCygwinBinPath();
            GeneralCommandLine cmd = new GeneralCommandLine();
            cmd.setWorkDirectory(cygwinBin);
            cmd.setExePath(new File(cygwinBin, "cygpath.exe").getCanonicalPath());
            cmd.addParameter(f.getCanonicalPath());
            ExecResult res = SimpleCommandLineProcessRunner.runCommandSecure(cmd, cmd.getCommandLineString(), null, new ProcessTimeoutCallback(30));
            Throwable error = res.getException();
            if (error != null)
                throw error;
            return res.getStdout().trim();
        } else {
            return f.getCanonicalPath();
        }
    } catch (Throwable e) {
        throw new VcsException("Error while resolving path " + f.getAbsolutePath() + ": " + e.getMessage(), e);
    }
}
Also used : ProcessTimeoutCallback(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.ProcessTimeoutCallback) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) VcsException(jetbrains.buildServer.vcs.VcsException) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) File(java.io.File) ExecResult(jetbrains.buildServer.ExecResult) NotNull(org.jetbrains.annotations.NotNull)

Example 57 with VcsException

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

the class GitPathResolverImpl method resolveGitPath.

public String resolveGitPath(final BuildAgentConfiguration agentConfiguration, String pathToResolve) throws VcsException {
    ValueResolver resolver = agentConfiguration.getParametersResolver();
    ProcessingResult result = resolver.resolve(pathToResolve);
    if (!result.isFullyResolved()) {
        throw new VcsException("The value is not fully resolved: " + result.getResult());
    }
    return result.getResult();
}
Also used : ValueResolver(jetbrains.buildServer.parameters.ValueResolver) VcsException(jetbrains.buildServer.vcs.VcsException) ProcessingResult(jetbrains.buildServer.parameters.ProcessingResult)

Example 58 with VcsException

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

the class Cleanup method repack.

private void repack(final File gcRepo) throws VcsException {
    long start = System.currentTimeMillis();
    GeneralCommandLine cmd = new GeneralCommandLine();
    cmd.setWorkingDirectory(gcRepo);
    cmd.setExePath(myConfig.getPathToGit());
    cmd.addParameter("repack");
    cmd.addParameters(myConfig.getRepackCommandArguments());
    ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, null, new SimpleCommandLineProcessRunner.RunCommandEventsAdapter() {

        @Override
        public Integer getOutputIdleSecondsTimeout() {
            return myConfig.getRepackIdleTimeoutSeconds();
        }

        @Override
        public void onProcessFinished(@NotNull final Process ps) {
            CLEANUP.info("[" + gcRepo.getName() + "] \"" + cmd.getCommandLineString() + "\" finished in " + TimePrinter.createMillisecondsFormatter().formatTime((System.currentTimeMillis() - start)));
        }
    });
    VcsException commandError = CommandLineUtil.getCommandLineError("git repack", result);
    if (commandError != null) {
        CLEANUP.warnAndDebugDetails("Error while running 'git repack' in \"" + gcRepo.getAbsolutePath() + "\"", commandError);
        throw commandError;
    }
}
Also used : SimpleCommandLineProcessRunner(jetbrains.buildServer.SimpleCommandLineProcessRunner) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) VcsException(jetbrains.buildServer.vcs.VcsException) ExecResult(jetbrains.buildServer.ExecResult)

Example 59 with VcsException

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

the class Cleanup method packRefs.

private void packRefs(@NotNull File gcRepo) throws VcsException {
    long start = System.currentTimeMillis();
    GeneralCommandLine cmd = new GeneralCommandLine();
    cmd.setWorkingDirectory(gcRepo);
    cmd.setExePath(myConfig.getPathToGit());
    cmd.addParameter("pack-refs");
    cmd.addParameters("--all");
    ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, null, new SimpleCommandLineProcessRunner.RunCommandEventsAdapter() {

        @Override
        public Integer getOutputIdleSecondsTimeout() {
            return myConfig.getPackRefsIdleTimeoutSeconds();
        }

        @Override
        public void onProcessFinished(@NotNull final Process ps) {
            CLEANUP.info("[" + gcRepo.getName() + "] 'git pack-refs --all' finished in " + (System.currentTimeMillis() - start) + "ms");
        }
    });
    VcsException commandError = CommandLineUtil.getCommandLineError("git pack-refs", result);
    if (commandError != null) {
        CLEANUP.warnAndDebugDetails("Error while running 'git pack-refs' in " + gcRepo.getAbsolutePath(), commandError);
        throw commandError;
    }
}
Also used : SimpleCommandLineProcessRunner(jetbrains.buildServer.SimpleCommandLineProcessRunner) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) VcsException(jetbrains.buildServer.vcs.VcsException) ExecResult(jetbrains.buildServer.ExecResult)

Example 60 with VcsException

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

the class GitDiagnosticsTab method fillModel.

@Override
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
    super.fillModel(model, request);
    model.put("nativeGitOperationsEnabled", myMainConfigProcessor.isNativeGitOperationsEnabled());
    model.put("isMultinodeSetup", myNodes.getNodes().size() > 1);
    try {
        final GitExec gitExec = myOperations.detectGit();
        model.put("gitExec", gitExec);
        model.put("isGitExecError", false);
        model.put("nativeGitOperationsSupported", myOperations.isNativeGitOperationsSupported(gitExec));
        model.put("projectsWithGitRoots", getProjectsWithGitRoots());
        model.put("projectGitRoots", getProjectGitRoots(request));
    } catch (VcsException e) {
        model.put("gitExecError", e);
        model.put("isGitExecError", true);
        model.put("nativeGitOperationsSupported", false);
    }
}
Also used : VcsException(jetbrains.buildServer.vcs.VcsException) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)

Aggregations

VcsException (jetbrains.buildServer.vcs.VcsException)79 File (java.io.File)34 NotNull (org.jetbrains.annotations.NotNull)22 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)13 IOException (java.io.IOException)12 TestFor (jetbrains.buildServer.util.TestFor)11 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)10 Method (java.lang.reflect.Method)10 ExecResult (jetbrains.buildServer.ExecResult)10 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)10 AfterMethod (org.testng.annotations.AfterMethod)10 BeforeMethod (org.testng.annotations.BeforeMethod)10 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)9 Repository (org.eclipse.jgit.lib.Repository)9 URIish (org.eclipse.jgit.transport.URIish)9 Nullable (org.jetbrains.annotations.Nullable)8 SimpleCommandLineProcessRunner (jetbrains.buildServer.SimpleCommandLineProcessRunner)5 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)5 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)5 RefSpec (org.eclipse.jgit.transport.RefSpec)5