use of org.sonar.scanner.ci.CiConfiguration in project sonarqube by SonarSource.
the class CirrusCiTest method log_warning_if_missing_commit_variable.
@Test
public void log_warning_if_missing_commit_variable() {
setEnvVariable("CIRRUS_PR", "1234");
CiConfiguration configuration = underTest.loadConfiguration();
assertThat(configuration.getScmRevision()).isEmpty();
assertThat(logs.logs(LoggerLevel.WARN)).contains("Missing environment variable CIRRUS_CHANGE_IN_REPO");
}
use of org.sonar.scanner.ci.CiConfiguration in project sonarqube by SonarSource.
the class ScmRevisionImplTest method ignore_failure_if_scm_does_not_support_revisions.
@Test
public void ignore_failure_if_scm_does_not_support_revisions() {
CiConfiguration ciConfiguration = mock(CiConfiguration.class);
when(ciConfiguration.getScmRevision()).thenReturn(Optional.empty());
Map<String, String> scannerConfiguration = new HashMap<>();
ScmConfiguration scmConfiguration = mock(ScmConfiguration.class, RETURNS_DEEP_STUBS);
when(scmConfiguration.provider().revisionId(any())).thenThrow(new UnsupportedOperationException("BOOM"));
InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
assertThat(underTest.get()).isEmpty();
}
use of org.sonar.scanner.ci.CiConfiguration in project sonarqube by SonarSource.
the class ScmRevisionImplTest method testGet.
private Optional<String> testGet(@Nullable String cliValue, @Nullable String ciValue, @Nullable String scmValue) {
CiConfiguration ciConfiguration = mock(CiConfiguration.class);
when(ciConfiguration.getScmRevision()).thenReturn(Optional.ofNullable(ciValue));
Map<String, String> scannerConfiguration = new HashMap<>();
scannerConfiguration.put("sonar.scm.revision", cliValue);
ScmConfiguration scmConfiguration = mock(ScmConfiguration.class, RETURNS_DEEP_STUBS);
when(scmConfiguration.provider().revisionId(any())).thenReturn(scmValue);
InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
return underTest.get();
}
use of org.sonar.scanner.ci.CiConfiguration in project sonarqube by SonarSource.
the class CodeMagicTest method loadConfiguration_commitEnvVariableNotAvailable_addScmRevisionToConfig.
@Test
public void loadConfiguration_commitEnvVariableNotAvailable_addScmRevisionToConfig() {
setEnvVariable("FCI_BUILD_ID", "1");
CiConfiguration ciConfiguration = underTest.loadConfiguration();
List<String> logs = logTester.logs(LoggerLevel.WARN);
assertThat(ciConfiguration.getScmRevision()).isEmpty();
assertThat(logs).hasSize(1);
assertThat(logs.get(0)).isEqualTo("Missing environment variable FCI_COMMIT");
}
Aggregations