Example #1
0
        public void Configure_XCopy_Sample_Project_With_Mocked_Environment()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock <IEnvironmentProvider>();

            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny <string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);

            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            // check if all template files are parsed
            var nupkg = new ZipPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));

            Assert.IsFalse(nupkg.GetFiles().Any(f => f.Path.Contains(".template.")));

            AssertPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"),
                          pkg => pkg.AssertFileContent(new Dictionary <string, string>()
            {
                {
                    "powerdeploy.xml",
                    @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <package type=""xcopy"" environment=""UNIT"">
                              <destination>c:\temp</destination>
                          </package>".ToXmlOneLine()
                },
                {
                    "App.config",
                    @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <configuration>
                            <appSettings>
                              <add key=""variable1"" value=""Val1"" />
                              <add key=""variable2"" value=""Val2"" />
                              <add key=""default.variable"" value=""defaultvalue"" />
                              <add key=""env"" value=""UNIT"" />
                            </appSettings>
                          </configuration>".ToXmlOneLine()
                }
            }));
        }
Example #2
0
        public void Deploy_XCopy_Package_Test()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock <IEnvironmentProvider>();

            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny <string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);

            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            target.DeployPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
        }
Example #3
0
        public void Configure_XCopy_Sample_Project_With_Mocked_Environment()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock<IEnvironmentProvider>();
            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny<string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);
            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            // check if all template files are parsed
            var nupkg = new ZipPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
            Assert.IsFalse(nupkg.GetFiles().Any(f => f.Path.Contains(".template.")));

            AssertPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"),
                pkg => pkg.AssertFileContent(new Dictionary<string, string>()
                {
                    {
                        "powerdeploy.xml",
                        @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <package type=""xcopy"" environment=""UNIT"">
                              <destination>c:\temp</destination>
                          </package>".ToXmlOneLine()
                    },
                    {
                        "App.config",
                        @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <configuration>
                            <appSettings>
                              <add key=""variable1"" value=""Val1"" />
                              <add key=""variable2"" value=""Val2"" />
                              <add key=""default.variable"" value=""defaultvalue"" />
                              <add key=""env"" value=""UNIT"" />
                            </appSettings>
                          </configuration>".ToXmlOneLine()
                    }
                }));
        }
Example #4
0
        public void Deserialize_XCopy_Package_Descriptor_Test()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock <IEnvironmentProvider>();

            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny <string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);

            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            var nupkg   = new ZipPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
            var options = nupkg.GetPackageOptions <XCopyOptions>();

            Assert.AreEqual("xcopy", nupkg.PeekPackageType());
            Assert.AreEqual(@"c:\temp", options.Destination);
            Assert.AreEqual("UNIT", options.Environment);
        }
        public TriggerDeploymentResponse Post(TriggerDeployment request)
        {
            using (var session = DocumentStore.OpenSession())
            {
                var environment = session.Query<Environment>().FirstOrDefault(e => e.Name == request.Environment);

                if (environment == null)
                {
                    throw HttpError.NotFound("Environment {0} not found.".Fmt(request.Environment));
                }

                var deploymentInfo = new Deployment()
                {
                    EnvironmentId = "environments/" + environment.Id,
                    RequestedAt = DateTime.UtcNow,
                };

                var packageInfo = session.Load<Package>("packages/{0}/{1}".Fmt(request.PackageId, request.Version));

                deploymentInfo.Package = packageInfo;
                deploymentInfo.Status = DeployStatus.Deploying;
                session.Store(deploymentInfo);

                session.SaveChanges();

                using (var workspace = new Workspace(FileSystem, ServerSettings))
                {
                    var neutralPackagePath = PackageDownloader.Downloaad(request.PackageId, request.Version, workspace.TempWorkDir);

                    workspace.UpdateSources();

                    var packageManager = new PackageManager(workspace.EnviornmentPath);
                    var configuredPackage = packageManager.ConfigurePackageByEnvironment(neutralPackagePath, request.Environment, workspace.TempWorkDir);
                    packageManager.DeployPackage(configuredPackage);
                    deploymentInfo.FinishedAt = DateTime.UtcNow;
                    deploymentInfo.Status = DeployStatus.Successful;
                    session.SaveChanges();

                    return new TriggerDeploymentResponse();
                }
            }
        }
Example #6
0
        public void Deploy_XCopy_Package_Test()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock<IEnvironmentProvider>();
            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny<string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);
            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            target.DeployPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
        }
Example #7
0
        public void Deserialize_XCopy_Package_Descriptor_Test()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock<IEnvironmentProvider>();
            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny<string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);
            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            var nupkg = new ZipPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
            var options = nupkg.GetPackageOptions<XCopyOptions>();

            Assert.AreEqual("xcopy", nupkg.PeekPackageType());
            Assert.AreEqual(@"c:\temp", options.Destination);
            Assert.AreEqual("UNIT", options.Environment);
        }