Package org.hivedb.teamcity.plugin

Source Code of org.hivedb.teamcity.plugin.GitVcsOnAgent

package org.hivedb.teamcity.plugin;

import java.io.File;

import jetbrains.buildServer.vcs.*;
import jetbrains.buildServer.agent.vcs.CheckoutOnAgentVcsSupport;
import jetbrains.buildServer.agent.BuildAgentConfiguration;
import jetbrains.buildServer.agent.BuildProgressLogger;

import org.apache.log4j.Logger;
import org.hivedb.teamcity.plugin.commands.CheckoutCommand;
import org.hivedb.teamcity.plugin.commands.CloneCommand;
import org.hivedb.teamcity.plugin.commands.FetchCommand;

public class GitVcsOnAgent implements CheckoutOnAgentVcsSupport {
  Logger log = Logger.getLogger(GitVcsOnAgent.class);

  public GitVcsOnAgent(BuildAgentConfiguration agentConf) {
  }

  public void updateSources(BuildProgressLogger logger, File workingDirectory, VcsRoot root, String version, IncludeRule includeRule) throws VcsException {
    GitConfiguration configuration = GitConfiguration.createAgentConfiguration(root, workingDirectory);
    if (!configuration.isProjectDirectoryARepository()) {
      workingDirectory.delete();
      CloneCommand cmd = new CloneCommand(configuration);
      cmd.run(false);
    }
    else {
      FetchCommand cmd = new FetchCommand(configuration);
      cmd.run();
    }
    new CheckoutCommand(configuration).forceCheckout(configuration.getRemoteBranch());
  }

  public String getName() {
    return "git";
  }
}
TOP

Related Classes of org.hivedb.teamcity.plugin.GitVcsOnAgent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.