Browse Source

MMF-3636 POC

task/eg/MMF-3636
Eric Giffon 1 month ago
parent
commit
515cdbc76b

+ 3
- 3
.cirrus.yml View File

@@ -14,7 +14,7 @@ env:
ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/SonarSource-sonar-scanner-cli-qa-deployer access_token]
ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa
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_USERNAME: VAULT[development/kv/data/burgr data.cirrus_username]
BURGR_PASSWORD: VAULT[development/kv/data/burgr data.cirrus_password]
@@ -76,7 +76,7 @@ linux_qa_java17_task:
env:
matrix:
- SQ_VERSION: LATEST_RELEASE[9.9]
- SQ_VERSION: DEV
# - SQ_VERSION: DEV
maven_cache:
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
qa_script:
@@ -102,7 +102,7 @@ win_qa_java17_task:
CIRRUS_SHELL: bash
matrix:
- SQ_VERSION: LATEST_RELEASE[9.9]
- SQ_VERSION: DEV
# - SQ_VERSION: DEV
maven_cache:
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
qa_script:

+ 5
- 5
pom.xml View File

@@ -64,9 +64,9 @@

<dependencies>
<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>
<groupId>com.google.code.findbugs</groupId>
@@ -179,8 +179,8 @@
<configuration>
<rules>
<requireFilesSize>
<minsize>560000</minsize>
<maxsize>600000</maxsize>
<minsize>1300000</minsize>
<maxsize>1370000</maxsize>
<files>
<file>${project.build.directory}/sonar-scanner-${project.version}.zip</file>
</files>

+ 1
- 0
src/main/java/org/sonarsource/scanner/cli/Conf.java View File

@@ -43,6 +43,7 @@ class Conf {
private static final String PROPERTY_PROJECT_CONFIG_FILE = "sonar.projectConfigFile";
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_SONARCLOUD_URL = "sonar.scanner.sonarcloud.url";

private final Cli cli;
private final Logs logger;

+ 4
- 2
src/main/java/org/sonarsource/scanner/cli/Main.java View File

@@ -90,12 +90,14 @@ public class Main {
}

static boolean isSonarCloud(Properties props) {
if (props.containsKey(Conf.PROPERTY_SONARCLOUD_URL)) {
return true;
}
String hostUrl = props.getProperty(Conf.PROPERTY_SONAR_HOST_URL);
if (hostUrl != null) {
return hostUrl.toLowerCase(Locale.ENGLISH).contains("sonarcloud");
}

return false;
return true;
}

private void checkSkip(Properties properties) {

+ 4
- 5
src/test/java/org/sonarsource/scanner/cli/ConfTest.java View File

@@ -19,6 +19,7 @@
*/
package org.sonarsource.scanner.cli;

import com.google.gson.JsonObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
@@ -33,7 +34,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
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.junit.Assume.assumeTrue;
@@ -327,11 +327,10 @@ public class ConfTest {
Properties properties = conf.properties();
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();
assertThat(properties.get("sonar.prop")).isEqualTo("expected");

+ 3
- 2
src/test/java/org/sonarsource/scanner/cli/MainTest.java View File

@@ -241,6 +241,7 @@ public class MainTest {
public void shouldLogServerVersion() {
when(scanner.serverVersion()).thenReturn("5.5");
Properties p = new Properties();
p.put(Conf.PROPERTY_SONAR_HOST_URL, "http://localhost:9000");
when(cli.isDisplayVersionOnly()).thenReturn(true);
when(cli.getInvokedFrom()).thenReturn("");
when(conf.properties()).thenReturn(p);
@@ -283,8 +284,8 @@ public class MainTest {

// SQSCANNER-57
@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

Loading…
Cancel
Save