protected BuildFinishedStatus runProcess()

in deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/cargo/CargoBuildProcessAdapter.java [84:130]


  protected BuildFinishedStatus runProcess() {
    try {
      final ConfigurationFactory configFactory = new DefaultConfigurationFactory();
      final Configuration configuration = configFactory.createConfiguration(myContainerType, ContainerType.REMOTE, ConfigurationType.RUNTIME);

      configuration.setProperty(RemotePropertySet.USERNAME, myUsername);
      configuration.setProperty(RemotePropertySet.PASSWORD, myPassword);
      configuration.setProperty(GeneralPropertySet.HOSTNAME, myHost);

      if (myUseHttps) {
        configuration.setProperty(GeneralPropertySet.PROTOCOL, "https");
      }

      if (!StringUtil.isEmpty(myPort)) {
        configuration.setProperty(ServletPropertySet.PORT, myPort);
      }


      final DefaultContainerFactory containerFactory = new DefaultContainerFactory();
      final Container container = containerFactory.createContainer(myContainerType, ContainerType.REMOTE, configuration);

      final DefaultDeployerFactory deployerFactory = new DefaultDeployerFactory();
      final Deployer deployer = deployerFactory.createDeployer(container);

      final DefaultDeployableFactory deployableFactory = new DefaultDeployableFactory();
      final Deployable deployable = deployableFactory.createDeployable(container.getId(), getLocation(mySourcePath), DeployableType.WAR);
      myLogger.message("Deploying [" + mySourcePath + "] to ["
          + configuration.getPropertyValue(GeneralPropertySet.HOSTNAME) + ":" + configuration.getPropertyValue(ServletPropertySet.PORT)
          + "], container type [" + myContainerType + "]");

      if (mySourcePath.endsWith("ROOT.war") && deployable instanceof WAR) {
        ((WAR) deployable).setContext("/");
      }

      final SimpleLogger simpleLogger = new SimpleLogger();
      simpleLogger.setLevel(LogLevel.DEBUG);
      deployer.setLogger(simpleLogger);
      deployer.redeploy(deployable);
      myLogger.message("Deploy finished.");
    } catch (CargoException e) {
      final String message = extractMessage(e);
      DeployerAgentUtils.logBuildProblem(myLogger, message);
      LOG.warnAndDebugDetails("Error executing Cargo command", e);
      return BuildFinishedStatus.FINISHED_FAILED;
    }
    return BuildFinishedStatus.FINISHED_SUCCESS;
  }