use of org.sonar.api.ce.posttask.QualityGate in project sonarqube by SonarSource.
the class PostProjectAnalysisTaskImpl method finished.
@Override
public void finished(ProjectAnalysis analysis) {
CeTask ceTask = analysis.getCeTask();
Project project = analysis.getProject();
QualityGate qualityGate = analysis.getQualityGate();
LOG.info("POSTASKPLUGIN: finished() CeTask[{}][{}] Project[{}] Date[{}] QualityGate[{}]", ceTask.getStatus(), ceTask.getId(), project.getKey(), analysis.getDate().getTime(), qualityGate == null ? null : qualityGate.getStatus());
}
use of org.sonar.api.ce.posttask.QualityGate in project sonarqube by SonarSource.
the class WebhookPayloadFactoryImplTest method create_payload_for_successful_analysis.
@Test
public void create_payload_for_successful_analysis() {
CeTask task = newCeTaskBuilder().setStatus(CeTask.Status.SUCCESS).setId("#1").build();
QualityGate gate = newQualityGateBuilder().setId("G1").setName("Gate One").setStatus(QualityGate.Status.WARN).add(newConditionBuilder().setMetricKey("coverage").setOperator(QualityGate.Operator.GREATER_THAN).setOnLeakPeriod(true).setWarningThreshold("75.0").setErrorThreshold("70.0").build(QualityGate.EvaluationStatus.WARN, "74.0")).build();
PostProjectAnalysisTask.ProjectAnalysis analysis = newAnalysis(task, gate, emptyMap());
WebhookPayload payload = underTest.create(analysis);
assertThat(payload.getProjectKey()).isEqualTo(PROJECT_KEY);
assertJson(payload.getJson()).isSimilarTo(getClass().getResource("WebhookPayloadTest/success.json"));
}
use of org.sonar.api.ce.posttask.QualityGate in project sonarqube by SonarSource.
the class WebhookPayloadFactoryImplTest method create_payload_with_gate_conditions_without_value.
@Test
public void create_payload_with_gate_conditions_without_value() {
CeTask task = newCeTaskBuilder().setStatus(CeTask.Status.SUCCESS).setId("#1").build();
QualityGate gate = newQualityGateBuilder().setId("G1").setName("Gate One").setStatus(QualityGate.Status.WARN).add(newConditionBuilder().setMetricKey("coverage").setOperator(QualityGate.Operator.GREATER_THAN).setWarningThreshold("75.0").setErrorThreshold("70.0").buildNoValue()).build();
PostProjectAnalysisTask.ProjectAnalysis analysis = newAnalysis(task, gate, emptyMap());
WebhookPayload payload = underTest.create(analysis);
assertThat(payload.getProjectKey()).isEqualTo(PROJECT_KEY);
assertJson(payload.getJson()).isSimilarTo(getClass().getResource("WebhookPayloadTest/gate_condition_without_value.json"));
}
use of org.sonar.api.ce.posttask.QualityGate in project sonarqube by SonarSource.
the class WebhookPayloadFactoryImplTest method create_payload_with_analysis_properties.
@Test
public void create_payload_with_analysis_properties() {
CeTask task = newCeTaskBuilder().setStatus(CeTask.Status.SUCCESS).setId("#1").build();
QualityGate gate = newQualityGateBuilder().setId("G1").setName("Gate One").setStatus(QualityGate.Status.WARN).build();
Map<String, String> scannerProperties = ImmutableMap.of("sonar.analysis.revision", "ab45d24", "sonar.analysis.buildNumber", "B123", "not.prefixed.with.sonar.analysis", "should be ignored", "ignored", "should be ignored too");
PostProjectAnalysisTask.ProjectAnalysis analysis = newAnalysis(task, gate, scannerProperties);
WebhookPayload payload = underTest.create(analysis);
assertJson(payload.getJson()).isSimilarTo(getClass().getResource("WebhookPayloadTest/with_analysis_properties.json"));
assertThat(payload.getJson()).doesNotContain("not.prefixed.with.sonar.analysis").doesNotContain("ignored");
}
Aggregations