public GitHubVersionsRepoUpdater(
     INupkgInfoFactory nupkgInfoFactory,
     GitHubAuth gitHubAuth,
     string versionsRepoOwner = null,
     string versionsRepo      = null)
     : this(
         gitHubAuth,
         new GitHubProject(versionsRepo ?? "versions", versionsRepoOwner),
         nupkgInfoFactory)
 {
 }
예제 #2
0
 public LocalVersionsRepoUpdater(INupkgInfoFactory nupkgInfoFactory) : base(nupkgInfoFactory)
 {
 }
        public GitHubVersionsRepoUpdater(GitHubAuth gitHubAuth, GitHubProject project, INupkgInfoFactory nupkgInfoFactory) : base(nupkgInfoFactory)
        {
            if (gitHubAuth == null)
            {
                throw new ArgumentNullException(nameof(gitHubAuth));
            }
            _gitHubAuth = gitHubAuth;

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }
            _project = project;
        }
예제 #4
0
 public PackageArtifactModelFactory(INupkgInfoFactory nupkgInfoFactory,
                                    TaskLoggingHelper logger)
 {
     _nupkgInfoFactory = nupkgInfoFactory;
     _log = logger;
 }
        public bool ExecuteTask(INupkgInfoFactory nupkgInfoFactory)
        {
            _nupkgInfoFactory = nupkgInfoFactory;

            HashSet <string> activeIgnorableErrorMessages = new HashSet <string>();

            // Add any "Ignore" messages that don't have conditionals to our active list.
            if (IgnoredErrorMessagesWithConditional != null)
            {
                foreach (var message in IgnoredErrorMessagesWithConditional)
                {
                    string conditional = message.GetMetadata("ConditionalErrorMessage");
                    if (string.IsNullOrEmpty(conditional))
                    {
                        activeIgnorableErrorMessages.Add(message.ItemSpec);
                    }
                }
            }
            for (int i = 0; i < MaxAttempts; i++)
            {
                string attemptMessage = $"(attempt {i + 1}/{MaxAttempts})";
                _runningExec = new Exec
                {
                    BuildEngine             = BuildEngine,
                    Command                 = Command,
                    LogStandardErrorAsError = false,
                    IgnoreExitCode          = true,
                    ConsoleToMSBuild        = true
                };
                if (!_runningExec.Execute())
                {
                    Log.LogError("Child Exec task failed to execute.");
                    break;
                }

                int exitCode = _runningExec.ExitCode;
                if (exitCode == 0 || FeedContainsIdenticalPackage())
                {
                    return(true);
                }

                if (_runningExec.ConsoleOutput != null &&
                    IgnoredErrorMessagesWithConditional != null &&
                    _runningExec.ConsoleOutput.Length > 0)
                {
                    var consoleOutput = _runningExec.ConsoleOutput.Select(c => c.ItemSpec);
                    // If the console output contains a "conditional" message, add the item to the active list.
                    var conditionMessages = IgnoredErrorMessagesWithConditional.Where(m =>
                                                                                      consoleOutput.Any(n =>
                                                                                                        n.Contains(m.GetMetadata("ConditionalErrorMessage"))));
                    foreach (var condition in conditionMessages)
                    {
                        activeIgnorableErrorMessages.Add(condition.ItemSpec);
                    }
                    // If an active "ignore" message is present in the console output, then return true instead of retrying.
                    foreach (var ignoreMessage in activeIgnorableErrorMessages)
                    {
                        if (consoleOutput.Any(c => c.Contains(ignoreMessage)))
                        {
                            Log.LogMessage(MessageImportance.High, $"Error detected, but error condition is valid, ignoring error \"{ignoreMessage}\"");
                            return(true);
                        }
                    }
                }
                string message = $"Exec FAILED: exit code {exitCode} {attemptMessage}";

                if (i + 1 == MaxAttempts || _cancelTokenSource.IsCancellationRequested)
                {
                    Log.LogError(message);
                    break;
                }

                Log.LogMessage(MessageImportance.High, message);

                TimeSpan delay = TimeSpan.FromSeconds(
                    Math.Pow(RetryDelayBase, i) + RetryDelayConstant);

                Log.LogMessage(MessageImportance.High, $"Retrying after {delay}...");

                try
                {
                    Task.Delay(delay, _cancelTokenSource.Token).Wait();
                }
                catch (AggregateException e) when(e.InnerException is TaskCanceledException)
                {
                    break;
                }
            }
            return(false);
        }
예제 #6
0
 public VersionsRepoUpdaterFactory(INupkgInfoFactory nupkgInfoFactory)
 {
     _nupkgInfoFactory = nupkgInfoFactory;
 }