|
|
@@ -20,6 +20,7 @@ |
|
|
|
package com.sonarsource.scanner.it; |
|
|
|
|
|
|
|
import com.sonar.orchestrator.build.BuildResult; |
|
|
|
import com.sonar.orchestrator.build.BuildRunner; |
|
|
|
import com.sonar.orchestrator.build.SonarScanner; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
@@ -140,7 +141,7 @@ public class ScannerTest extends ScannerTestCase { |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void should_use_environment_props() { |
|
|
|
public void should_use_json_environment_props() { |
|
|
|
SonarScanner build = newScanner(new File("projects/simple-sample-no-properties")) |
|
|
|
.setEnvironmentVariable("SONARQUBE_SCANNER_PARAMS", "{" |
|
|
|
+ "\"sonar.projectKey\" : \"sample\"," + |
|
|
@@ -151,6 +152,18 @@ public class ScannerTest extends ScannerTestCase { |
|
|
|
orchestrator.executeBuild(build); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void should_use_environment_prop() { |
|
|
|
SonarScanner build = newScanner(new File("projects/simple-sample")) |
|
|
|
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org"); |
|
|
|
|
|
|
|
BuildRunner runner = new BuildRunner(orchestrator.getConfiguration()); |
|
|
|
BuildResult buildResult = runner.runQuietly(null, build); |
|
|
|
|
|
|
|
assertThat(buildResult.isSuccess()).isFalse(); |
|
|
|
assertThat(buildResult.getLogs()).contains("SonarQube server [http://from-env.org] can not be reached"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void should_skip_analysis() { |
|
|
|
SonarScanner build = newScanner(new File("projects/simple-sample")) |
|
|
@@ -164,11 +177,13 @@ public class ScannerTest extends ScannerTestCase { |
|
|
|
@Test |
|
|
|
public void should_fail_if_unable_to_connect() { |
|
|
|
SonarScanner build = newScanner(new File("projects/simple-sample")) |
|
|
|
//env property should be overridden |
|
|
|
.setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org") |
|
|
|
.setProperty("sonar.host.url", "http://foo"); |
|
|
|
|
|
|
|
BuildResult result = orchestrator.executeBuildQuietly(build); |
|
|
|
// expect build failure |
|
|
|
assertThat(result.getStatus()).isNotEqualTo(0); |
|
|
|
assertThat(result.isSuccess()).isFalse(); |
|
|
|
// with the following message |
|
|
|
assertThat(result.getLogs()).contains("SonarQube server [http://foo] can not be reached"); |
|
|
|
} |