ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/SonarSource-sonar-scanner-cli-qa-deployer access_token] | ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/SonarSource-sonar-scanner-cli-qa-deployer access_token] | ||||
ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa | ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa | ||||
ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token] | ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token] | ||||
BURGR_URL: VAULT[development/kv/data/burgr data.url] | BURGR_URL: VAULT[development/kv/data/burgr data.url] | ||||
BURGR_USERNAME: VAULT[development/kv/data/burgr data.cirrus_username] | BURGR_USERNAME: VAULT[development/kv/data/burgr data.cirrus_username] | ||||
BURGR_PASSWORD: VAULT[development/kv/data/burgr data.cirrus_password] | BURGR_PASSWORD: VAULT[development/kv/data/burgr data.cirrus_password] | ||||
env: | env: | ||||
matrix: | matrix: | ||||
- SQ_VERSION: LATEST_RELEASE[9.9] | - SQ_VERSION: LATEST_RELEASE[9.9] | ||||
- SQ_VERSION: DEV | |||||
# - SQ_VERSION: DEV | |||||
maven_cache: | maven_cache: | ||||
folder: ${CIRRUS_WORKING_DIR}/.m2/repository | folder: ${CIRRUS_WORKING_DIR}/.m2/repository | ||||
qa_script: | qa_script: | ||||
CIRRUS_SHELL: bash | CIRRUS_SHELL: bash | ||||
matrix: | matrix: | ||||
- SQ_VERSION: LATEST_RELEASE[9.9] | - SQ_VERSION: LATEST_RELEASE[9.9] | ||||
- SQ_VERSION: DEV | |||||
# - SQ_VERSION: DEV | |||||
maven_cache: | maven_cache: | ||||
folder: ${CIRRUS_WORKING_DIR}/.m2/repository | folder: ${CIRRUS_WORKING_DIR}/.m2/repository | ||||
qa_script: | qa_script: |
<dependencies> | <dependencies> | ||||
<dependency> | <dependency> | ||||
<groupId>org.sonarsource.scanner.api</groupId> | |||||
<artifactId>sonar-scanner-api</artifactId> | |||||
<version>2.16.3.1081</version> | |||||
<groupId>org.sonarsource.scanner.commons</groupId> | |||||
<artifactId>sonar-scanner-commons</artifactId> | |||||
<version>2.17.0.1464</version> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>com.google.code.findbugs</groupId> | <groupId>com.google.code.findbugs</groupId> | ||||
<configuration> | <configuration> | ||||
<rules> | <rules> | ||||
<requireFilesSize> | <requireFilesSize> | ||||
<minsize>560000</minsize> | |||||
<maxsize>600000</maxsize> | |||||
<minsize>1300000</minsize> | |||||
<maxsize>1370000</maxsize> | |||||
<files> | <files> | ||||
<file>${project.build.directory}/sonar-scanner-${project.version}.zip</file> | <file>${project.build.directory}/sonar-scanner-${project.version}.zip</file> | ||||
</files> | </files> |
private static final String PROPERTY_PROJECT_CONFIG_FILE = "sonar.projectConfigFile"; | private static final String PROPERTY_PROJECT_CONFIG_FILE = "sonar.projectConfigFile"; | ||||
private static final String SONAR_PROJECT_PROPERTIES_FILENAME = "sonar-project.properties"; | private static final String SONAR_PROJECT_PROPERTIES_FILENAME = "sonar-project.properties"; | ||||
static final String PROPERTY_SONAR_HOST_URL = "sonar.host.url"; | static final String PROPERTY_SONAR_HOST_URL = "sonar.host.url"; | ||||
static final String PROPERTY_SONARCLOUD_URL = "sonar.scanner.sonarcloud.url"; | |||||
private final Cli cli; | private final Cli cli; | ||||
private final Logs logger; | private final Logs logger; |
} | } | ||||
static boolean isSonarCloud(Properties props) { | static boolean isSonarCloud(Properties props) { | ||||
if (props.containsKey(Conf.PROPERTY_SONARCLOUD_URL)) { | |||||
return true; | |||||
} | |||||
String hostUrl = props.getProperty(Conf.PROPERTY_SONAR_HOST_URL); | String hostUrl = props.getProperty(Conf.PROPERTY_SONAR_HOST_URL); | ||||
if (hostUrl != null) { | if (hostUrl != null) { | ||||
return hostUrl.toLowerCase(Locale.ENGLISH).contains("sonarcloud"); | return hostUrl.toLowerCase(Locale.ENGLISH).contains("sonarcloud"); | ||||
} | } | ||||
return false; | |||||
return true; | |||||
} | } | ||||
private void checkSkip(Properties properties) { | private void checkSkip(Properties properties) { |
*/ | */ | ||||
package org.sonarsource.scanner.cli; | package org.sonarsource.scanner.cli; | ||||
import com.google.gson.JsonObject; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.net.URISyntaxException; | import java.net.URISyntaxException; | ||||
import java.nio.file.Files; | import java.nio.file.Files; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.junit.rules.ExpectedException; | import org.junit.rules.ExpectedException; | ||||
import org.junit.rules.TemporaryFolder; | import org.junit.rules.TemporaryFolder; | ||||
import org.sonarsource.scanner.api.internal.shaded.minimaljson.Json; | |||||
import static org.assertj.core.api.Assertions.assertThat; | import static org.assertj.core.api.Assertions.assertThat; | ||||
import static org.junit.Assume.assumeTrue; | import static org.junit.Assume.assumeTrue; | ||||
Properties properties = conf.properties(); | Properties properties = conf.properties(); | ||||
assertThat(properties.get("sonar.prop")).isEqualTo("default"); | assertThat(properties.get("sonar.prop")).isEqualTo("default"); | ||||
String jsonString = Json.object() | |||||
.add("project.settings", home.resolve("conf/sq-project.properties").toAbsolutePath().toString()) | |||||
.toString(); | |||||
JsonObject jsonObject = new JsonObject(); | |||||
jsonObject.addProperty("project.settings", home.resolve("conf/sq-project.properties").toAbsolutePath().toString()); | |||||
env.put("SONARQUBE_SCANNER_PARAMS", jsonString); | |||||
env.put("SONARQUBE_SCANNER_PARAMS", jsonObject.toString()); | |||||
properties = conf.properties(); | properties = conf.properties(); | ||||
assertThat(properties.get("sonar.prop")).isEqualTo("expected"); | assertThat(properties.get("sonar.prop")).isEqualTo("expected"); |
public void shouldLogServerVersion() { | public void shouldLogServerVersion() { | ||||
when(scanner.serverVersion()).thenReturn("5.5"); | when(scanner.serverVersion()).thenReturn("5.5"); | ||||
Properties p = new Properties(); | Properties p = new Properties(); | ||||
p.put(Conf.PROPERTY_SONAR_HOST_URL, "http://localhost:9000"); | |||||
when(cli.isDisplayVersionOnly()).thenReturn(true); | when(cli.isDisplayVersionOnly()).thenReturn(true); | ||||
when(cli.getInvokedFrom()).thenReturn(""); | when(cli.getInvokedFrom()).thenReturn(""); | ||||
when(conf.properties()).thenReturn(p); | when(conf.properties()).thenReturn(p); | ||||
// SQSCANNER-57 | // SQSCANNER-57 | ||||
@Test | @Test | ||||
public void should_return_false_is_sonar_cloud_host_is_null() { | |||||
assertThat(Main.isSonarCloud(new Properties())).isFalse(); | |||||
public void should_return_true_is_sonar_cloud_host_is_null() { | |||||
assertThat(Main.isSonarCloud(new Properties())).isTrue(); | |||||
} | } | ||||
@Test | @Test |