Exemple #1
0
        public static bool TryCreateFromLocalBuild(string buildDirectory, out InsertionArtifacts artifacts)
        {
            if (buildDirectory.EndsWith(ArtifactName, StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine($"Using artifacts provided in BuildDropPath: {buildDirectory}");
                artifacts = new ArcadeInsertionArtifacts(buildDirectory);
                return(true);
            }

            artifacts = null;
            return(false);
        }
Exemple #2
0
        public static bool TryCreateFromLocalBuild(string buildDirectory, out InsertionArtifacts artifacts)
        {
            if (buildDirectory.EndsWith(@"artifacts\VSSetup\Debug", StringComparison.OrdinalIgnoreCase) ||
                buildDirectory.EndsWith(@"artifacts\VSSetup\Release", StringComparison.OrdinalIgnoreCase))
            {
                artifacts = new ArcadeInsertionArtifacts(buildDirectory);
                return(true);
            }

            artifacts = null;
            return(false);
        }
Exemple #3
0
        internal static async Task <InsertionArtifacts> GetInsertionArtifactsAsync(Build build, CancellationToken cancellationToken)
        {
            // used for local testing:
            if (LegacyInsertionArtifacts.TryCreateFromLocalBuild(Options.BuildDropPath, out var artifacts) ||
                ArcadeInsertionArtifacts.TryCreateFromLocalBuild(Options.BuildDropPath, out artifacts))
            {
                return(artifacts);
            }

            var buildClient = ProjectCollection.GetClient <BuildHttpClient>();

            Debug.Assert(ReferenceEquals(build,
                                         (await GetInsertableBuildsAsync(buildClient, cancellationToken, new[] { build })).Single()));

            // Pull the VSSetup directory from artifacts store.
            var buildArtifacts = await buildClient.GetArtifactsAsync(build.Project.Id, build.Id, cancellationToken);

            // The artifact name passed to PublishBuildArtifacts task:
            var arcadeArtifactName = ArcadeInsertionArtifacts.ArtifactName;
            var legacyArtifactName = LegacyInsertionArtifacts.GetArtifactName(build.BuildNumber);

            foreach (var artifact in buildArtifacts)
            {
                if (artifact.Name == arcadeArtifactName)
                {
                    // artifact.Resource.Data should be available and non-null due to BuildWithValidArtifactsAsync,
                    // which checks this precondition
                    if (!StringComparer.OrdinalIgnoreCase.Equals(artifact.Resource.Type, "container"))
                    {
                        throw new InvalidOperationException($"Could not find artifact '{arcadeArtifactName}' associated with build '{build.Id}'");
                    }

                    return(new ArcadeInsertionArtifacts(await DownloadArtifactsAsync(buildClient, build, artifact, cancellationToken)));
                }
                else if (artifact.Name == legacyArtifactName)
                {
                    // artifact.Resource.Data should be available and non-null due to BuildWithValidArtifactsAsync,
                    // which checks this precondition
                    if (string.Compare(artifact.Resource.Type, "container", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // This is a build where the artifacts are published to the artifacts server instead of a UNC path.
                        // Download this artifacts to a temp folder and provide that path instead.
                        return(new LegacyInsertionArtifacts(await DownloadArtifactsAsync(buildClient, build, artifact, cancellationToken)));
                    }

                    return(new LegacyInsertionArtifacts(Path.Combine(artifact.Resource.Data, build.BuildNumber)));
                }
            }

            // Should never happen since we already filtered for containing valid paths
            throw new InvalidOperationException("Could not find drop path");
        }