Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ALM manual override + debug logs #11

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.14.1-paypay
version=1.14.2-paypay
Original file line number Diff line number Diff line change
Expand Up @@ -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<AlmSettingDto> 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<ProjectAlmSettingDto> optionalProjectAlmSettingDto =
dbClient.projectAlmSettingDao().selectByProject(dbSession, projectAnalysis.getProject().getUuid());

if (optionalProjectAlmSettingDto.isEmpty()) {
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(
"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);

}

Expand Down