diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java index 934bc94e0..8dab23acf 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java @@ -293,6 +293,10 @@ public String getAnalysisProjectKey() { return project.getKey(); } + public String getAnalysisProjectName() { + return project.getName(); + } + public List findFailedConditions() { return qualityGate.getConditions().stream().filter(c -> c.getStatus() == QualityGate.EvaluationStatus.ERROR) .collect(Collectors.toList()); diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java index 3fa142c62..42e0c2688 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java @@ -127,7 +127,7 @@ public DecorationResult createCheckRun(AnalysisDetails analysisDetails, AlmSetti Map inputObjectArguments = new HashMap<>(); inputObjectArguments.put("repositoryId", repositoryAuthenticationToken.getRepositoryId()); - inputObjectArguments.put("name", "Sonarqube Results"); + inputObjectArguments.put("name", String.format("%s Sonarqube Results", analysisDetails.getAnalysisProjectName())); inputObjectArguments.put("status", RequestableCheckStatusState.COMPLETED); inputObjectArguments.put("conclusion", QualityGate.Status.OK == analysisDetails.getQualityGateStatus() ? CheckConclusionState.SUCCESS : CheckConclusionState.FAILURE); diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java index 0c027be32..ccf1b9075 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java @@ -354,6 +354,7 @@ private void createCheckRunHappyPath(QualityGate.Status status, String basePath, when(analysisDetails.createAnalysisSummary(any())).thenReturn("dummy summary"); when(analysisDetails.getCommitSha()).thenReturn("commit SHA"); when(analysisDetails.getAnalysisProjectKey()).thenReturn("projectKey"); + when(analysisDetails.getAnalysisProjectName()).thenReturn("projectName"); when(analysisDetails.getBranchName()).thenReturn("branchName"); when(analysisDetails.getAnalysisDate()).thenReturn(new Date(1234567890)); when(analysisDetails.getAnalysisId()).thenReturn("analysis ID"); @@ -486,7 +487,7 @@ private void createCheckRunHappyPath(QualityGate.Status status, String basePath, assertThat(annotationArgumentCaptor.getValue()).isEqualTo(expectedAnnotationObjects); verify(inputObjectBuilders.get(position + 1)).put(eq("repositoryId"), eq("repository ID")); - verify(inputObjectBuilders.get(position + 1)).put(eq("name"), eq("Sonarqube Results")); + verify(inputObjectBuilders.get(position + 1)).put(eq("name"), eq("projectName Sonarqube Results")); verify(inputObjectBuilders.get(position + 1)).put(eq("headSha"), eq("commit SHA")); verify(inputObjectBuilders.get(position + 1)).put(eq("status"), eq(RequestableCheckStatusState.COMPLETED)); verify(inputObjectBuilders.get(position + 1)).put(eq("conclusion"), eq(status == QualityGate.Status.OK ?