use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class ScmTest method scm_optimization.
@Test
public void scm_optimization() throws Exception {
SonarScanner build = SonarScanner.create(projectDir("scm/xoo-sample-with-scm")).setProperty("sonar.scm.provider", "xoo").setProperty("sonar.scm.disabled", "false");
// First run
BuildResult buildResult = orchestrator.executeBuild(build);
assertThat(getScmData("sample-scm:src/main/xoo/sample/Sample.xoo")).containsExactly(MapEntry.entry(1, new LineData("1", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(3, new LineData("2", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(4, new LineData("1", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(8, new LineData("3", "2014-01-04T00:00:00+0000", "toto")));
assertThat(buildResult.getLogs()).containsSequence("1 files to be analyzed", "1/1 files analyzed");
// Second run with same file should not trigger blame but SCM data are copied from previous analysis
buildResult = orchestrator.executeBuild(build);
assertThat(getScmData("sample-scm:src/main/xoo/sample/Sample.xoo")).containsExactly(MapEntry.entry(1, new LineData("1", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(3, new LineData("2", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(4, new LineData("1", "2013-01-04T00:00:00+0000", "jhenry")), MapEntry.entry(8, new LineData("3", "2014-01-04T00:00:00+0000", "toto")));
assertThat(buildResult.getLogs()).doesNotContain("1 files to be analyzed");
assertThat(buildResult.getLogs()).doesNotContain("1/1 files analyzed");
// Now if SCM is explicitely disabled it should clear SCM data on server side
buildResult = orchestrator.executeBuild(build.setProperty("sonar.scm.disabled", "true"));
assertThat(getScmData("sample-scm:src/main/xoo/sample/Sample.xoo")).isEmpty();
assertThat(buildResult.getLogs()).doesNotContain("1 files to be analyzed");
assertThat(buildResult.getLogs()).doesNotContain("1/1 files analyzed");
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method test_status_error.
@Test
public void test_status_error() throws IOException {
QualityGate simple = qgClient().create("SimpleWithLowThreshold");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").errorThreshold("10"));
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("ERROR");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method ad_hoc_build_break_strategy.
@Test
public void ad_hoc_build_break_strategy() throws IOException {
QualityGate simple = qgClient().create("SimpleWithLowThresholdForBuildBreakStrategy");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").errorThreshold("7"));
try {
File projectDir = projectDir("qualitygate/xoo-sample");
SonarScanner build = SonarScanner.create(projectDir);
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_ERROR);
String taskId = getTaskIdInLocalReport(projectDir);
String analysisId = getAnalysisId(taskId);
ProjectStatusWsResponse projectStatusWsResponse = wsClient.qualityGates().projectStatus(new ProjectStatusWsRequest().setAnalysisId(analysisId));
ProjectStatusWsResponse.ProjectStatus projectStatus = projectStatusWsResponse.getProjectStatus();
assertThat(projectStatus.getStatus()).isEqualTo(ProjectStatusWsResponse.Status.ERROR);
assertThat(projectStatus.getConditionsCount()).isEqualTo(1);
ProjectStatusWsResponse.Condition condition = projectStatus.getConditionsList().get(0);
assertThat(condition.getMetricKey()).isEqualTo("ncloc");
assertThat(condition.getErrorThreshold()).isEqualTo("7");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method test_status_ok.
@Test
public void test_status_ok() throws IOException {
QualityGate simple = qgClient().create("SimpleWithHighThreshold");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("40"));
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_OK);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("OK");
} finally {
qgClient().unsetDefault();
qgClient().destroy(simple.id());
}
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class IssuesModeTest method issues_analysis_on_new_project.
@Test
public void issues_analysis_on_new_project() throws IOException {
restoreProfile("one-issue-per-line.xml");
orchestrator.getServer().provisionProject("sample", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
SonarScanner runner = configureRunnerIssues("shared/xoo-sample", null, "sonar.verbose", "true");
BuildResult result = orchestrator.executeBuild(runner);
assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
}
Aggregations