Exemple #1
0
 public async Task <SearchIssue> CreateWorkItem(
     [ActivityTrigger] CIContext context,
     ILogger log
     )
 {
     return(await _sonarCloudRepository.GetIssues(context.PullRequestId, context.ProjectKey));
 }
Exemple #2
0
        public async Task <IEnumerable <SecurityBot.Model.Issue> > GetIssuesAsync(
            [ActivityTrigger] IDurableActivityContext context,
            ILogger logger)
        {
            var decorationContext = context.GetInput <DecoratorContext>();

            var searchIssue = await _repository.GetIssues(decorationContext.PullRequestId,
                                                          decorationContext.Tag.GetValueOrDefault(SonarCloudConfiguration.ProjectKey));

            var issues = new List <Issue>();

            foreach (var issue in searchIssue.issues)
            {
                var projectKey = decorationContext.Tag.GetValueOrDefault(SonarCloudConfiguration.ProjectKey);
                var path       = issue.component.Replace($"{projectKey}:", "");
                var newIssue   = new Issue()
                {
                    Id       = issue.key,
                    Type     = issue.type,
                    Message  = issue.message,
                    Url      = $"https://sonarcloud.io/project/issues?id={projectKey}&open={issue.key}&pullRequest={decorationContext.PullRequestId}&resolved=false",
                    Provider = SonarCloudConfiguration.ProviderName
                };

                newIssue.Path = path != projectKey ? path : null;
                issues.Add(newIssue);
            }
            return(issues);
        }
Exemple #3
0
        public async Task <Issue> GetIssueAsync([ActivityTrigger] IDurableActivityContext context, ILogger logger)
        {
            var getIssueContext            = context.GetInput <GetIssueContext>();
            var parentCreatedReviewComment = getIssueContext.CreatedReviewComment;


            var projectKey = parentCreatedReviewComment.Tag.GetValueOrDefault(SonarCloudConfiguration.ProjectKey);

            var searchIssue = await _repository.GetIssues(getIssueContext.PullRequestId,
                                                          projectKey, parentCreatedReviewComment.IssueId);

            return(searchIssue.issues.Select(p => new Issue()
            {
                Id = p.key,
                Type = p.type,
                Message = p.message,
                Status = p.status,
                Url = $"https://sonarcloud.io/project/issues?id={projectKey}&open={p.key}&pullRequest={getIssueContext.PullRequestId}",
                Provider = SonarCloudConfiguration.ProviderName
            }).FirstOrDefault());
        }