Exemple #1
0
        public override async Task ExecuteAsync()
        {
            _loggerService.WriteHeading("PUBLISHING MCR DOCS");

            // Hookup a TraceListener in order to capture details from Microsoft.DotNet.VersionTools
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            IEnumerable <GitObject> gitObjects =
                GetUpdatedReadmes()
                .Concat(GetUpdatedTagsMetadata());

            foreach (GitObject gitObject in gitObjects)
            {
                _loggerService.WriteMessage(
                    $"Updated file '{gitObject.Path}' with contents:{Environment.NewLine}{gitObject.Content}{Environment.NewLine}");
            }

            if (!Options.IsDryRun)
            {
                using IGitHubClient gitHubClient = _gitHubClientFactory.GetClient(Options.GitOptions.ToGitHubAuth(), Options.IsDryRun);

                await RetryHelper.GetWaitAndRetryPolicy <HttpRequestException>(_loggerService).ExecuteAsync(async() =>
                {
                    GitReference gitRef = await GitHelper.PushChangesAsync(gitHubClient, Options, $"Mirroring readmes", branch =>
                    {
                        return(FilterUpdatedGitObjectsAsync(gitObjects, gitHubClient, branch));
                    });

                    if (gitRef != null)
                    {
                        _loggerService.WriteMessage(PipelineHelper.FormatOutputVariable("readmeCommitDigest", gitRef.Object.Sha));
                    }
                });
            }
        }
Exemple #2
0
        protected async Task ImportImageAsync(string destTagName, string destRegistryName, string srcTagName,
                                              string?srcRegistryName = null, string?srcResourceId = null, ImportSourceCredentials?sourceCredentials = null)
        {
            AzureCredentials credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
                Options.ServicePrincipal.ClientId,
                Options.ServicePrincipal.Secret,
                Options.ServicePrincipal.Tenant,
                AzureEnvironment.AzureGlobalCloud);
            IAzure azure = AzureManagementFactory.CreateAzureManager(credentials, Options.Subscription);

            ImportImageParametersInner importParams = new ImportImageParametersInner()
            {
                Mode   = "Force",
                Source = new ImportSource(
                    srcTagName,
                    srcResourceId,
                    srcRegistryName,
                    sourceCredentials),
                TargetTags = new string[] { destTagName }
            };

            LoggerService.WriteMessage($"Importing '{destTagName}' from '{srcTagName}'");

            if (!Options.IsDryRun)
            {
                try
                {
                    await RetryHelper.GetWaitAndRetryPolicy <Exception>(LoggerService)
                    .ExecuteAsync(() => azure.ContainerRegistries.Inner.ImportImageAsync(Options.ResourceGroup, destRegistryName, importParams));
                }
                catch (Exception e)
                {
                    string errorMsg = $"Importing Failure: {destTagName}";
                    if (e is CloudException cloudException)
                    {
                        errorMsg += Environment.NewLine + cloudException.Body.Message;
                    }

                    errorMsg += Environment.NewLine + e.ToString();

                    LoggerService.WriteMessage(errorMsg);

                    throw;
                }
            }
        }
Exemple #3
0
 public Task <GitCommit> GetCommitAsync(string commitId, Guid repositoryId) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _gitHttpClient.GetCommitAsync(commitId, repositoryId));
Exemple #4
0
 public Task <GitItem> GetItemAsync(Guid repositoryId, string path, GitVersionDescriptor?versionDescriptor = null) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _gitHttpClient.GetItemAsync(repositoryId, path, versionDescriptor: versionDescriptor));
Exemple #5
0
 public Task <GitPush> CreatePushAsync(GitPush push, Guid repositoryId) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _gitHttpClient.CreatePushAsync(push, repositoryId));
Exemple #6
0
 public Task <List <GitRef> > GetBranchRefsAsync(Guid repositoryId) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _gitHttpClient.GetBranchRefsAsync(repositoryId));
Exemple #7
0
 public Task <List <GitRepository> > GetRepositoriesAsync() =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _gitHttpClient.GetRepositoriesAsync());
Exemple #8
0
 public Task <List <string> > AddBuildTagAsync(Guid project, int buildId, string tag) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _inner.AddBuildTagAsync(project, buildId, tag));
Exemple #9
0
 public Task <TeamProject> GetProjectAsync(string projectId) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _inner.GetProject(projectId));
Exemple #10
0
 public Task <IPagedList <WebApi.Build> > GetBuildsAsync(Guid projectId, IEnumerable <int> definitions = null, WebApi.BuildStatus?statusFilter = null) =>
 RetryHelper.GetWaitAndRetryPolicy <Exception>(_loggerService)
 .ExecuteAsync(() => _inner.GetBuildsAsync2(projectId, definitions: definitions, statusFilter: statusFilter));