use of org.sonar.server.qualitygate.notification.QGChangeNotification in project sonarqube by SonarSource.
the class QualityGateEventsStep method notifyUsers.
/**
* @param rawStatus OK or ERROR + optional text
*/
private void notifyUsers(Component project, QualityGateStatus rawStatus, boolean isNewAlert) {
QGChangeNotification notification = new QGChangeNotification();
notification.setDefaultMessage(String.format("Alert on %s: %s", project.getName(), rawStatus.getStatus().getLabel())).setFieldValue("projectName", project.getName()).setFieldValue("projectKey", project.getKey()).setFieldValue("projectVersion", project.getProjectAttributes().getProjectVersion()).setFieldValue("alertName", rawStatus.getStatus().getLabel()).setFieldValue("alertText", rawStatus.getText()).setFieldValue("alertLevel", rawStatus.getStatus().toString()).setFieldValue("isNewAlert", Boolean.toString(isNewAlert));
Branch branch = analysisMetadataHolder.getBranch();
if (!branch.isMain()) {
notification.setFieldValue("branch", branch.getName());
}
List<Metric> ratingMetrics = metricRepository.getMetricsByType(MetricType.RATING);
String ratingMetricsInOneString = ratingMetrics.stream().map(Metric::getName).collect(Collectors.joining(","));
notification.setFieldValue("ratingMetrics", ratingMetricsInOneString);
notificationService.deliverEmails(singleton(notification));
// compatibility with old API
notificationService.deliver(notification);
}
Aggregations