Exemplo n.º 1
0
        public void TestMergeBuildManifests()
        {
            var orchestratedModel = new OrchestratedBuildModel(new BuildIdentity("Orchestrated", "123"))
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed("http://example.org")
                }
            };

            orchestratedModel.AddParticipantBuild(CreatePackageOnlyBuildManifestModel());
            orchestratedModel.AddParticipantBuild(BuildModel.Parse(XElement.Parse(ExampleBuildString)));

            XElement modelXml = orchestratedModel.ToXml();
            XElement xml      = XElement.Parse(@"
<OrchestratedBuild Name=""Orchestrated"" BuildId=""123"">
  <Endpoint Id=""Orchestrated"" Type=""BlobFeed"" Url=""http://example.org"">
    <Package Id=""Foo"" Version=""1.2.3-example"" />
    <Package Id=""runtime.rhel.6-x64.Microsoft.Private.CoreFx.NETCoreApp"" Version=""4.5.0-preview1-25929-04"" Category=""noship"" />
    <Package Id=""System.Memory"" Version=""4.5.0-preview1-25927-01"" />
    <Blob Id=""symbols/inner/blank-dir-nonshipping"" NonShipping=""false"" />
    <Blob Id=""symbols/runtime.rhel.6-x64.Microsoft.Private.CoreFx.NETCoreApp.4.5.0-preview1-25929-04.symbols.nupkg"" />
    <Blob Id=""symbols/System.ValueTuple.4.5.0-preview1-25929-04.symbols.nupkg"" NonShipping=""true"" />
  </Endpoint>
  <Build Name=""SimpleBuildManifest"" BuildId=""123"" />
  <Build Name=""corefx"" BuildId=""20171129-04"" Branch=""master"" Commit=""defb6d52047cc3d6b5f5d0853b0afdb1512dfbf4"" />
</OrchestratedBuild>");

            Assert.True(XNode.DeepEquals(xml, modelXml));
        }
Exemplo n.º 2
0
        public void TestExampleBuildManifestRoundtrip()
        {
            XElement xml      = XElement.Parse(ExampleBuildString);
            var      model    = BuildModel.Parse(xml);
            XElement modelXml = model.ToXml();

            XNode.DeepEquals(xml, modelXml).Should().BeTrue("Model failed to output the parsed XML.");
        }
Exemplo n.º 3
0
        public void TestExampleCustomBuildIdentityRoundtrip()
        {
            XElement xml = XElement.Parse(
                @"<Build Name=""Example"" BuildId=""123"" ProductVersion=""1.0.0-preview"" Branch=""master"" Commit=""abcdef"" BlankExtra="""" Extra=""extra-foo"" />");
            var      model    = BuildModel.Parse(xml);
            XElement modelXml = model.ToXml();

            XNode.DeepEquals(xml, modelXml).Should().BeTrue("Model failed to output the parsed XML.");
        }
Exemplo n.º 4
0
 public static BuildModel ManifestFileToModel(string assetManifestPath, TaskLoggingHelper log)
 {
     try
     {
         return(BuildModel.Parse(XElement.Load(assetManifestPath)));
     }
     catch (Exception e)
     {
         log.LogError($"Could not parse asset manifest file: {assetManifestPath}");
         log.LogErrorFromException(e);
         return(null);
     }
 }
        public override bool Execute()
        {
            // Leave out attributes if they would just have empty string values.
            if (ManifestBranch == string.Empty)
            {
                ManifestBranch = null;
            }
            if (ManifestCommit == string.Empty)
            {
                ManifestCommit = null;
            }

            var identity = new BuildIdentity
            {
                Name         = ManifestName,
                BuildId      = ManifestBuildId,
                Branch       = ManifestBranch,
                Commit       = ManifestCommit,
                IsStable     = IsStable,
                VersionStamp = VersionStamp
            };

            var orchestratedBuild = new OrchestratedBuildModel(identity)
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed(BlobFeedUrl)
                }
            };

            foreach (ITaskItem buildManifestFile in BuildManifestFiles)
            {
                string contents = System.IO.File.ReadAllText(buildManifestFile.ItemSpec);

                BuildModel build = BuildModel.Parse(XElement.Parse(contents));

                foreach (PackageArtifactModel package in build.Artifacts.Packages)
                {
                    package.OriginBuildName = build.Identity.Name;
                }

                orchestratedBuild.AddParticipantBuild(build);
            }

            System.IO.File.WriteAllText(File, orchestratedBuild.ToXml().ToString());

            return(!Log.HasLoggedErrors);
        }
        public override bool Execute()
        {
            // Leave out attributes if they would just have empty string values.
            if (ManifestBranch == string.Empty)
            {
                ManifestBranch = null;
            }
            if (ManifestCommit == string.Empty)
            {
                ManifestCommit = null;
            }

            var orchestratedBuild = new OrchestratedBuildModel(new BuildIdentity(
                                                                   ManifestName,
                                                                   ManifestBuildId,
                                                                   ManifestBranch,
                                                                   ManifestCommit))
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed(BlobFeedUrl)
                }
            };

            foreach (ITaskItem buildManifestFile in BuildManifestFiles)
            {
                string contents = System.IO.File.ReadAllText(buildManifestFile.ItemSpec);

                BuildModel build = BuildModel.Parse(XElement.Parse(contents));
                orchestratedBuild.AddParticipantBuild(build);
            }

            System.IO.File.WriteAllText(File, orchestratedBuild.ToXml().ToString());

            return(!Log.HasLoggedErrors);
        }
Exemplo n.º 7
0
        private async Task PushBuildManifestAsync(
            BlobFeedAction blobFeedAction,
            IEnumerable <BlobArtifactModel> blobArtifacts,
            IEnumerable <PackageArtifactModel> packageArtifacts)
        {
            bool disabledByBlob = await blobFeedAction.feed.CheckIfBlobExists(
                $"{blobFeedAction.feed.RelativePath}{DisableManifestPushConfigurationBlob}");

            if (disabledByBlob)
            {
                Log.LogMessage(
                    MessageImportance.Normal,
                    $"Skipping manifest push: feed has '{DisableManifestPushConfigurationBlob}'.");
                return;
            }

            string blobPath = $"{AssetsVirtualDir}{ManifestAssetOutputDir}{ManifestName}.xml";

            string existingStr = await blobFeedAction.feed.DownloadBlobAsString(
                $"{blobFeedAction.feed.RelativePath}{blobPath}");

            BuildModel buildModel;

            if (existingStr != null)
            {
                buildModel = BuildModel.Parse(XElement.Parse(existingStr));
            }
            else
            {
                buildModel = new BuildModel(
                    new BuildIdentity(
                        ManifestName,
                        ManifestBuildId,
                        ManifestBranch,
                        ManifestCommit));
            }

            buildModel.Artifacts.Blobs.AddRange(blobArtifacts);
            buildModel.Artifacts.Packages.AddRange(packageArtifacts);

            string tempFile = null;

            try
            {
                tempFile = Path.GetTempFileName();

                File.WriteAllText(tempFile, buildModel.ToXml().ToString());

                var item = new MSBuild.TaskItem(tempFile, new Dictionary <string, string>
                {
                    ["RelativeBlobPath"] = blobPath
                });

                using (var clientThrottle = new SemaphoreSlim(MaxClients, MaxClients))
                {
                    await blobFeedAction.UploadAssets(
                        item,
                        clientThrottle,
                        UploadTimeoutInMinutes,
                        allowOverwrite : true);
                }
            }
            finally
            {
                if (tempFile != null)
                {
                    File.Delete(tempFile);
                }
            }
        }