Ejemplo n.º 1
0
        private void AddEnvironmentIndexViewModel(
            IList<EnvironmentIndexViewModel> viewModels,
            Environment environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("environment");
            }

            if (viewModels == null)
            {
                throw new ArgumentNullException("viewModels");
            }

            IEnumerable<Deployment> deployments =
                _deploymentRepository.GetByEnvironment(
                    environment.Id);
            Deployment lastDeployment =
                deployments.Where(d => d.Completed.HasValue).OrderByDescending(d => d.Completed).FirstOrDefault();
            if (lastDeployment == null)
            {
                return;
            }

            Pipeline pipeline = _pipelineRepository.GetPipeline(lastDeployment.PipelineId);
            string currentRevision = pipeline.Revision;
            viewModels.Add(new EnvironmentIndexViewModel
                {
                    EnvironmentId = environment.Id,
                    EnvironmentName = environment.EnvironmentName,
                    CurrentRevision = currentRevision
                });
        }
 public void Deploy(
     string packagePath,
     string workingDirectory,
     Environment environment)
 {
     ExtractZipFile(packagePath, workingDirectory);
     WriteEnvironmentProperties(environment, workingDirectory);
     DeployPackage(workingDirectory);
 }
 private void SetupRepositories(
     int pipelineId,
     int environmentId)
 {
     var environment = new Environment();
     var pipeline = new Pipeline(
         pipelineId,
         "A",
         1,
         "x",
         "x",
         DateTime.Now,
         "x",
         "x");
     environmentRepositoryMock.Setup(
         er => er.GetEnvironment(environmentId)).Returns(
             environment);
     pipelineRepositoryMock.Setup(
         pr => pr.GetPipeline(pipelineId)).Returns(
             pipeline);
 }
        private static void WriteEnvironmentProperties(
            Environment environment,
            string workingDirectory)
        {
            var sb = new StringBuilder();
            sb.AppendLine("<?xml version=\"1.0\"?>");
            sb.AppendLine("<properties>");
            foreach (EnvironmentProperty property in environment.Properties)
            {
                sb.AppendFormat(
                    "  <property name=\"{0}\" value=\"{1}\" />",
                    property.Key,
                    property.Value);
                sb.AppendLine();
            }

            sb.AppendLine("</properties>");
            string properties = sb.ToString();
            string filePath =
                Path.Combine(workingDirectory, "local.properties.xml");
            File.WriteAllText(filePath, properties);
        }