From 95868e61624a57a4a4c721baf4a255dc3b5fece1 Mon Sep 17 00:00:00 2001 From: tara-san <139845913+tara-san@users.noreply.github.com> Date: Tue, 10 Oct 2023 13:07:29 +0900 Subject: [PATCH 1/3] Allow ALM manual override + debug logs --- .../PullRequestPostAnalysisTask.java | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java index fef96bbc7..07c39eacc 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java @@ -73,20 +73,44 @@ public void finished(Context context) { LOGGER.warn("No pull request ID has been submitted with the Pull Request. Analysis will be skipped"); return; } - ProjectAlmSettingDto projectAlmSettingDto = new ProjectAlmSettingDto(); String enablePrDecoration = Optional.ofNullable(System.getenv("ENABLE_PR_DECORATION")) .orElse(projectAnalysis.getScannerContext().getProperties().getOrDefault("sonar.analysis.enableprdecoration", "true")); LOGGER.info("sonar.analysis.enableprdecoration: {}", enablePrDecoration); + + ProjectAlmSettingDto projectAlmSettingDto; Optional optionalAlmSettingDto; try (DbSession dbSession = dbClient.openSession(false)) { - projectAlmSettingDto.setAlmRepo(projectAnalysis.getScannerContext().getProperties().getOrDefault( - "sonar.pullrequest.github.repository", "Pay-Baymax/" + projectAnalysis.getProject().getKey())); - projectAlmSettingDto.setAlmSettingUuid("AXxy3BubdvWBwkcdvIfk"); - projectAlmSettingDto.setAlmSlug(""); - projectAlmSettingDto.setProjectUuid(projectAnalysis.getProject().getUuid()); - projectAlmSettingDto.setSummaryCommentEnabled(Boolean.parseBoolean(enablePrDecoration)); - optionalAlmSettingDto = dbClient.almSettingDao().selectByUuid(dbSession, "AXxy3BubdvWBwkcdvIfk"); + + Optional optionalProjectAlmSettingDto = + dbClient.projectAlmSettingDao().selectByProject(dbSession, projectAnalysis.getProject().getUuid()); + + if (optionalProjectAlmSettingDto.isEmpty()) { + LOGGER.info("No ALM has been set on the current project, try using default hardcoded PayPay values"); + + ProjectAlmSettingDto paypayAlmSettingsDto = new ProjectAlmSettingDto(); + paypayAlmSettingsDto.setAlmRepo(projectAnalysis.getScannerContext().getProperties().getOrDefault( + "sonar.pullrequest.github.repository", "Pay-Baymax/" + projectAnalysis.getProject().getKey())); + paypayAlmSettingsDto.setAlmSettingUuid("AXxy3BubdvWBwkcdvIfk"); + paypayAlmSettingsDto.setAlmSlug(""); + paypayAlmSettingsDto.setProjectUuid(projectAnalysis.getProject().getUuid()); + paypayAlmSettingsDto.setSummaryCommentEnabled(Boolean.parseBoolean(enablePrDecoration)); + + optionalProjectAlmSettingDto = Optional.of(paypayAlmSettingsDto); + } + + projectAlmSettingDto = optionalProjectAlmSettingDto.get(); + + LOGGER.info("FINAL ALM:" + + " projectUuid=" + projectAlmSettingDto.getProjectUuid() + + " almSettingsUuid=" + projectAlmSettingDto.getAlmSettingUuid() + + " almRepo=" + projectAlmSettingDto.getAlmRepo() + + " almSlug=" + projectAlmSettingDto.getAlmSlug() + + " monorepo=" + projectAlmSettingDto.getMonorepo() + + " summaryCommentEnabled=" + projectAlmSettingDto.getSummaryCommentEnabled()); + + String almSettingUuid = projectAlmSettingDto.getAlmSettingUuid(); + optionalAlmSettingDto = dbClient.almSettingDao().selectByUuid(dbSession, almSettingUuid); } From 131390162dea3718605fabf5a1e9083cb73995c4 Mon Sep 17 00:00:00 2001 From: tara-san <139845913+tara-san@users.noreply.github.com> Date: Tue, 10 Oct 2023 13:16:17 +0900 Subject: [PATCH 2/3] Bump version to 1.14.2-paypay --- .env | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index e8ca89be9..3c681db02 100644 --- a/.env +++ b/.env @@ -5,4 +5,4 @@ SONARQUBE_VERSION=9.8-community DOCKERFILE=release.Dockerfile # The version of the plugin to include in the image -PLUGIN_VERSION=1.14.1-paypay +PLUGIN_VERSION=1.14.2-paypay diff --git a/gradle.properties b/gradle.properties index 687584be0..d7637a610 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=1.14.1-paypay +version=1.14.2-paypay From cb942aacc90c2b7d93c90baf6d6068aebaac43bf Mon Sep 17 00:00:00 2001 From: tara-san <139845913+tara-san@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:48:40 +0900 Subject: [PATCH 3/3] Update src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java Co-authored-by: David Kuo --- .../plugin/ce/pullrequest/PullRequestPostAnalysisTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java index 07c39eacc..72e76f980 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestPostAnalysisTask.java @@ -86,7 +86,7 @@ public void finished(Context context) { dbClient.projectAlmSettingDao().selectByProject(dbSession, projectAnalysis.getProject().getUuid()); if (optionalProjectAlmSettingDto.isEmpty()) { - LOGGER.info("No ALM has been set on the current project, try using default hardcoded PayPay values"); + LOGGER.info("No ALM has been set on the current project; using default hardcoded PayPay values"); ProjectAlmSettingDto paypayAlmSettingsDto = new ProjectAlmSettingDto(); paypayAlmSettingsDto.setAlmRepo(projectAnalysis.getScannerContext().getProperties().getOrDefault(