private async Task EnsureLabelsAsync()
        {
            GitHubConnectionOptions options = _githubOptions.Value;
            IGitHubClient           client  = await _gitHubClientFactory.CreateGitHubClientAsync(options.Organization, options.Repository);

            await GitHubModifications.TryCreateAsync(
                () => client.Issue.Labels.Create(
                    options.Organization,
                    options.Repository,
                    new NewLabel(_githubOptions.Value.RcaLabel, "009999")),
                _logger
                );
        }
        /// <summary>
        /// Creates/updates the github issue.
        /// </summary>
        /// <param name="updateHistoryError">Error info for which github issue has to be created</param>
        /// <param name="issueRepo">Repository where the github issue is created</param>
        /// <param name="shouldReplaceDescription">Func that carries info the description has to be replaced </param>
        /// <param name="description">Description for the issue body / comment body</param>
        /// <returns></returns>
        private async Task CreateOrUpdateGithubIssueAsync(
            RepositoryBranchUpdateHistoryEntry updateHistoryError,
            string issueRepo,
            Func <string, string, bool> shouldReplaceDescription,
            string description)
        {
            _logger.LogInformation($"Error Message : '{updateHistoryError.ErrorMessage}' in repository :  '{updateHistoryError.Repository}'");
            IReliableDictionary <(string repository, string branch), int> gitHubIssueEvaluator =
                await _stateManager.GetOrAddAsync <IReliableDictionary <(string repository, string branch), int> >("gitHubIssueEvaluator");

            var           parseRepoUri = ParseRepoUri(issueRepo);
            IGitHubClient client       = await _authenticateGitHubClient.CreateGitHubClientAsync(parseRepoUri.owner, parseRepoUri.repo);

            Octokit.Repository repo = await client.Repository.Get(
                parseRepoUri.owner,
                parseRepoUri.repo);

            var issueNumber = new ConditionalValue <int>();

            using (ITransaction tx = _stateManager.CreateTransaction())
            {
                issueNumber = await gitHubIssueEvaluator.TryGetValueAsync(
                    tx,
                    (updateHistoryError.Repository,
                     updateHistoryError.Branch));

                await tx.CommitAsync();
            }
            if (issueNumber.HasValue)
            {
                Issue issue = await client.Issue.Get(repo.Id, issueNumber.Value);

                // check if the issue is open only then update it else create a new issue and update the dictionary.
                if (issue.State.Equals("Open"))
                {
                    _logger.LogInformation($@"Updating a gitHub issue number : '{issueNumber}' for the error : '{updateHistoryError.ErrorMessage}' for the repository : '{updateHistoryError.Repository}'");
                    await UpdateIssueAsync(
                        client,
                        updateHistoryError,
                        shouldReplaceDescription,
                        description,
                        issue,
                        repo.Id);

                    return;
                }
            }
            // Create a new issue for the error if the issue is already closed or the issue does not exists.
            _logger.LogInformation($@"Creating a new gitHub issue for dependency Update Error, for the error message : '{updateHistoryError.ErrorMessage} for the repository : '{updateHistoryError.Repository}'");
            await CreateIssueAsync(
                client,
                updateHistoryError,
                gitHubIssueEvaluator,
                description,
                repo.Id,
                issueRepo);
        }
        private async Task ProcessBuildNotificationsAsync(Build build)
        {
            const string fullBranchPrefix = "refs/heads/";

            foreach (var monitor in _options.Value.Monitor.Builds)
            {
                if (!string.Equals(build.Project.Name, monitor.Project, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (!string.Equals(monitor.DefinitionPath, $"{build.Definition.Path}\\{build.Definition.Name}", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (monitor.Branches.All(mb => !string.Equals($"{fullBranchPrefix}{mb}",
                                                              build.SourceBranch,
                                                              StringComparison.OrdinalIgnoreCase)))
                {
                    continue;
                }

                string prettyBranch = build.SourceBranch;
                if (prettyBranch.StartsWith(fullBranchPrefix))
                {
                    prettyBranch = prettyBranch.Substring(fullBranchPrefix.Length);
                }

                _logger.LogInformation(
                    "Build '{buildNumber}' in project '{projectName}' with definition '{definitionPath}' and branch '{branch}' matches monitoring criteria, sending notification",
                    build.BuildNumber,
                    build.Project.Name,
                    build.Definition.Path,
                    build.SourceBranch);

                _logger.LogInformation("Fetching timeline messages...");
                string timelineMessage = await BuildTimelineMessage(build);

                _logger.LogInformation("Fetching changes messages...");
                string changesMessage = await BuildChangesMessage(build);

                BuildMonitorOptions.IssuesOptions repo = _options.Value.Issues;
                IGitHubClient github = await _gitHubClientFactory.CreateGitHubClientAsync(repo.Owner, repo.Name);

                DateTimeOffset?finishTime = DateTimeOffset.TryParse(build.FinishTime, out var parsedFinishTime) ?parsedFinishTime: (DateTimeOffset?)null;
                DateTimeOffset?startTime  = DateTimeOffset.TryParse(build.StartTime, out var parsedStartTime) ? parsedStartTime:(DateTimeOffset?)null;

                string timeString     = "";
                string durationString = "";
                if (finishTime.HasValue)
                {
                    timeString = finishTime.Value.ToString("R");
                    if (startTime.HasValue)
                    {
                        durationString = ((int)(finishTime.Value - startTime.Value).TotalMinutes) + " minutes";
                    }
                }

                string icon = build.Result == "failed" ? ":x:" : ":warning:";

                string body = @$ "Build [#{build.BuildNumber}]({build.Links.Web.Href}) {build.Result}

## {icon} : {build.Project.Name} / {build.Definition.Name} {build.Result}

### Summary
**Finished** - {timeString}
**Duration** - {durationString}
**Requested for** - {build.RequestedFor.DisplayName}
**Reason** - {build.Reason}

### Details

{timelineMessage}

### Changes

{changesMessage}