aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-01-11 16:44:38 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2016-01-11 17:28:15 +0100
commit8d6e9a735a3ac5c6a729861e776c687d5639e9c1 (patch)
tree58d9b6d8401e9a70809162b0eb6d2da39f37d2da
parent5e187f8dc1099ce63c00b9185b9a8a8d9ce92f92 (diff)
downloadsonar-scanner-cli-8d6e9a735a3ac5c6a729861e776c687d5639e9c1.tar.gz
sonar-scanner-cli-8d6e9a735a3ac5c6a729861e776c687d5639e9c1.zip
Update ITs and enable Dory analysis
-rw-r--r--.travis.yml8
-rw-r--r--it/pom.xml4
-rw-r--r--it/src/test/java/com/sonar/runner/it/CacheTest.java11
-rw-r--r--it/src/test/java/com/sonar/runner/it/JavaTest.java39
-rw-r--r--it/src/test/java/com/sonar/runner/it/MultimoduleTest.java31
-rw-r--r--it/src/test/java/com/sonar/runner/it/RunnerTestCase.java70
-rw-r--r--it/src/test/java/com/sonar/runner/it/ScannerTestCase.java62
-rw-r--r--it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java (renamed from it/src/test/java/com/sonar/runner/it/SonarRunnerTestSuite.java)14
-rwxr-xr-xtravis.sh98
9 files changed, 196 insertions, 141 deletions
diff --git a/.travis.yml b/.travis.yml
index bb57a38..0527f82 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,10 +9,10 @@ script: ./travis.sh
env:
matrix:
- - PR_ANALYSIS=true
- - RUN_ITS=true SQ_VERSION=DEV
- - RUN_ITS=true SQ_VERSION=5.1.2
- - RUN_ITS=true SQ_VERSION=LTS
+ - TARGET=CI
+ - TARGET=IT SQ_VERSION=DEV
+ - TARGET=IT SQ_VERSION=5.1.2
+ - TARGET=IT SQ_VERSION=LTS
cache:
directories:
diff --git a/it/pom.xml b/it/pom.xml
index b2f243c..3c1aa0d 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -31,7 +31,7 @@
<dependency>
<groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
- <version>3.8</version>
+ <version>3.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -66,7 +66,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
- <include>**/SonarRunnerTestSuite.java</include>
+ <include>**/SonarScannerTestSuite.java</include>
</includes>
</configuration>
</plugin>
diff --git a/it/src/test/java/com/sonar/runner/it/CacheTest.java b/it/src/test/java/com/sonar/runner/it/CacheTest.java
index 82abe07..8a7d704 100644
--- a/it/src/test/java/com/sonar/runner/it/CacheTest.java
+++ b/it/src/test/java/com/sonar/runner/it/CacheTest.java
@@ -25,6 +25,7 @@ import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.ResourceLocation;
import java.io.File;
import java.io.IOException;
+import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -33,7 +34,7 @@ import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
-public class CacheTest extends RunnerTestCase {
+public class CacheTest extends ScannerTestCase {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@@ -42,12 +43,18 @@ public class CacheTest extends RunnerTestCase {
@BeforeClass
public static void setUpClass() {
+ orchestrator.resetData();
orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
orchestrator.getServer().provisionProject("java:sample", "Java Sample, with comma");
orchestrator.getServer().associateProjectToQualityProfile("java:sample", "java", "sonar-way");
serverRunning = true;
}
+ @AfterClass
+ public static void restartForOtherTests() {
+ ensureStarted();
+ }
+
private static void ensureStarted() {
if (!serverRunning) {
orchestrator.start();
@@ -142,7 +149,7 @@ public class CacheTest extends RunnerTestCase {
currentTemp = temp.newFolder();
}
- SonarRunner runner = newRunner(new File("projects/" + project))
+ SonarRunner runner = newScanner(new File("projects/" + project))
.setProperty("sonar.analysis.mode", mode)
.setProperty("sonar.userHome", currentTemp.getAbsolutePath());
diff --git a/it/src/test/java/com/sonar/runner/it/JavaTest.java b/it/src/test/java/com/sonar/runner/it/JavaTest.java
index a9ece3b..2d0c2fb 100644
--- a/it/src/test/java/com/sonar/runner/it/JavaTest.java
+++ b/it/src/test/java/com/sonar/runner/it/JavaTest.java
@@ -22,6 +22,10 @@ package com.sonar.runner.it;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.ResourceLocation;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -30,18 +34,19 @@ import org.sonar.wsclient.issue.IssueQuery;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
-public class JavaTest extends RunnerTestCase {
+public class JavaTest extends ScannerTestCase {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
+ @After
+ public void cleanup() {
+ orchestrator.resetData();
+ }
+
/**
* No bytecode, only sources
*/
@@ -51,7 +56,7 @@ public class JavaTest extends RunnerTestCase {
orchestrator.getServer().provisionProject("java:sample", "Java Sample, with comma");
orchestrator.getServer().associateProjectToQualityProfile("java:sample", "java", "sonar-way");
- SonarRunner build = newRunner(new File("projects/java-sample"))
+ SonarRunner build = newScanner(new File("projects/java-sample"))
.setProperty("sonar.verbose", "true")
.addArguments("-e");
// SONARPLUGINS-3061
@@ -97,7 +102,7 @@ public class JavaTest extends RunnerTestCase {
orchestrator.getServer().provisionProject("java:bytecode", "Java Bytecode Sample");
orchestrator.getServer().associateProjectToQualityProfile("java:bytecode", "java", "requires-bytecode");
- SonarRunner build = newRunner(new File("projects/java-bytecode"));
+ SonarRunner build = newScanner(new File("projects/java-bytecode"));
orchestrator.executeBuild(build);
Resource project = orchestrator.getServer().getWsClient().find(new ResourceQuery("java:bytecode").setMetrics("lcom4", "violations"));
@@ -129,7 +134,7 @@ public class JavaTest extends RunnerTestCase {
orchestrator.getServer().provisionProject("java:basedir-with-source", "Basedir with source");
orchestrator.getServer().associateProjectToQualityProfile("java:basedir-with-source", "java", "sonar-way");
- SonarRunner build = newRunner(new File("projects/basedir-with-source"));
+ SonarRunner build = newScanner(new File("projects/basedir-with-source"));
orchestrator.executeBuild(build);
Resource project = orchestrator.getServer().getWsClient().find(new ResourceQuery("java:basedir-with-source").setMetrics("files", "ncloc"));
@@ -146,7 +151,7 @@ public class JavaTest extends RunnerTestCase {
orchestrator.getServer().provisionProject("SAMPLE", "Java Sample, with comma");
orchestrator.getServer().associateProjectToQualityProfile("SAMPLE", "java", "sonar-way");
- SonarRunner build = newRunner(new File("projects/java-sample"))
+ SonarRunner build = newScanner(new File("projects/java-sample"))
.setProjectKey("SAMPLE");
orchestrator.executeBuild(build);
@@ -160,7 +165,7 @@ public class JavaTest extends RunnerTestCase {
*/
@Test
public void should_override_working_dir_with_relative_path() {
- SonarRunner build = newRunner(new File("projects/override-working-dir"))
+ SonarRunner build = newScanner(new File("projects/override-working-dir"))
.setProperty("sonar.working.directory", ".overridden-relative-sonar");
orchestrator.executeBuild(build);
@@ -174,7 +179,7 @@ public class JavaTest extends RunnerTestCase {
@Test
public void should_override_working_dir_with_absolute_path() {
File projectHome = new File("projects/override-working-dir");
- SonarRunner build = newRunner(projectHome)
+ SonarRunner build = newScanner(projectHome)
.setProperty("sonar.working.directory", new File(projectHome, ".overridden-absolute-sonar").getAbsolutePath());
orchestrator.executeBuild(build);
@@ -187,7 +192,7 @@ public class JavaTest extends RunnerTestCase {
*/
@Test
public void should_fail_if_source_dir_does_not_exist() {
- SonarRunner build = newRunner(new File("projects/bad-source-dirs"));
+ SonarRunner build = newScanner(new File("projects/bad-source-dirs"));
BuildResult result = orchestrator.executeBuildQuietly(build);
assertThat(result.getStatus()).isNotEqualTo(0);
@@ -201,7 +206,7 @@ public class JavaTest extends RunnerTestCase {
@Test
public void should_log_message_when_deprecated_properties_are_used() {
assumeTrue(!orchestrator.getServer().version().isGreaterThanOrEquals("4.3"));
- SonarRunner build = newRunner(new File("projects/using-deprecated-props"));
+ SonarRunner build = newScanner(new File("projects/using-deprecated-props"));
BuildResult result = orchestrator.executeBuild(build);
String logs = result.getLogs();
@@ -216,7 +221,7 @@ public class JavaTest extends RunnerTestCase {
*/
@Test
public void should_warn_when_analysis_is_platform_dependent() {
- SonarRunner build = newRunner(new File("projects/java-sample"))
+ SonarRunner build = newScanner(new File("projects/java-sample"))
// ORCH-243
.setSourceEncoding("");
String log = orchestrator.executeBuild(build).getLogs();
@@ -230,21 +235,21 @@ public class JavaTest extends RunnerTestCase {
@Test
public void should_fail_if_unable_to_connect() {
- SonarRunner build = newRunner(new File("projects/java-sample"))
+ SonarRunner build = newScanner(new File("projects/java-sample"))
.setProperty("sonar.host.url", "http://foo");
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
assertThat(result.getStatus()).isNotEqualTo(0);
// with the following message
- assertThat(result.getLogs()).contains("server 'http://foo' can not be reached");
+ assertThat(result.getLogs()).contains("SonarQube server [http://foo] can not be reached");
}
// SONARPLUGINS-3574
@Test
public void run_from_external_location() throws IOException {
File tempDir = temp.newFolder();
- SonarRunner build = newRunner(tempDir)
+ SonarRunner build = newScanner(tempDir)
.setProperty("sonar.projectBaseDir", new File("projects/java-sample").getAbsolutePath())
.addArguments("-e");
orchestrator.executeBuild(build);
diff --git a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java b/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
index c8941b2..b09ca8d 100644
--- a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
+++ b/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
@@ -21,22 +21,27 @@ package com.sonar.runner.it;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarRunner;
+import java.io.File;
+import org.junit.After;
import org.junit.Test;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
-import java.io.File;
-
import static org.fest.assertions.Assertions.assertThat;
-public class MultimoduleTest extends RunnerTestCase {
+public class MultimoduleTest extends ScannerTestCase {
+
+ @After
+ public void cleanup() {
+ orchestrator.resetData();
+ }
/**
* SONARPLUGINS-2202
*/
@Test
public void test_simplest_with_props_on_root() {
- SonarRunner build = newRunner(new File("projects/multi-module/simplest/simplest-with-props-on-root"));
+ SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-root"));
orchestrator.executeBuild(build);
@@ -67,7 +72,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_multi_language_with_same_projectdir() {
- SonarRunner build = newRunner(new File("projects/multi-module/multi-language"));
+ SonarRunner build = newScanner(new File("projects/multi-module/multi-language"));
orchestrator.executeBuild(build);
@@ -90,7 +95,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_simplest_with_props_on_each_module() {
- SonarRunner build = newRunner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
+ SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
orchestrator.executeBuild(build);
@@ -113,7 +118,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_warning_when_source_folder_on_root_module() {
- SonarRunner build = newRunner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
+ SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
assertThat(orchestrator.executeBuild(build).getLogs()).contains("/!\\ A multi-module project can't have source folders");
}
@@ -123,7 +128,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_deep_path_for_modules() {
- SonarRunner build = newRunner(new File("projects/multi-module/customization/deep-path-for-modules"));
+ SonarRunner build = newScanner(new File("projects/multi-module/customization/deep-path-for-modules"));
orchestrator.executeBuild(build);
@@ -146,7 +151,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_module_path_with_space() {
- SonarRunner build = newRunner(new File("projects/multi-module/customization/module-path-with-space"));
+ SonarRunner build = newScanner(new File("projects/multi-module/customization/module-path-with-space"));
orchestrator.executeBuild(build);
@@ -169,7 +174,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_overwriting_parent_properties() {
- SonarRunner build = newRunner(new File("projects/multi-module/customization/overwriting-parent-properties"));
+ SonarRunner build = newScanner(new File("projects/multi-module/customization/overwriting-parent-properties"));
orchestrator.executeBuild(build);
@@ -195,7 +200,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void test_using_config_file_property() {
- SonarRunner build = newRunner(new File("projects/multi-module/advanced/using-config-file-prop"));
+ SonarRunner build = newScanner(new File("projects/multi-module/advanced/using-config-file-prop"));
orchestrator.executeBuild(build);
@@ -218,7 +223,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void should_fail_if_unexisting_base_dir() {
- SonarRunner build = newRunner(new File("projects/multi-module/failures/unexisting-base-dir"));
+ SonarRunner build = newScanner(new File("projects/multi-module/failures/unexisting-base-dir"));
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
@@ -233,7 +238,7 @@ public class MultimoduleTest extends RunnerTestCase {
*/
@Test
public void should_fail_if_unexisting_config_file() {
- SonarRunner build = newRunner(new File("projects/multi-module/failures/unexisting-config-file"));
+ SonarRunner build = newScanner(new File("projects/multi-module/failures/unexisting-config-file"));
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
diff --git a/it/src/test/java/com/sonar/runner/it/RunnerTestCase.java b/it/src/test/java/com/sonar/runner/it/RunnerTestCase.java
deleted file mode 100644
index 79a1edd..0000000
--- a/it/src/test/java/com/sonar/runner/it/RunnerTestCase.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SonarSource :: IT :: SonarQube Scanner
- * Copyright (C) 2009 SonarSource
- * sonarqube@googlegroups.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package com.sonar.runner.it;
-
-import com.sonar.orchestrator.version.Version;
-
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.OrchestratorBuilder;
-import com.sonar.orchestrator.build.SonarRunner;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-
-import java.io.File;
-
-public abstract class RunnerTestCase {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- public static Orchestrator orchestrator = null;
-
- @BeforeClass
- public static void startServer() {
- OrchestratorBuilder builder = Orchestrator.builderEnv()
- // TODO Java projects should be replaced by Xoo projects
- .setOrchestratorProperty("javaVersion", "LATEST_RELEASE")
- .addPlugin("java")
- .setOrchestratorProperty("findbugsVersion", "LATEST_RELEASE")
- .addPlugin("findbugs")
- .setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE")
- .addPlugin("javascript");
-
- orchestrator = builder.build();
- orchestrator.start();
- }
-
- @AfterClass
- public static void stopServer() {
- if (orchestrator != null) {
- orchestrator.stop();
- orchestrator = null;
- }
- }
-
- SonarRunner newRunner(File baseDir, String... keyValueProperties) {
- SonarRunner runner = SonarRunner.create(baseDir, keyValueProperties);
- String runnerVersion = Version.create(orchestrator.getConfiguration().getString("sonarRunner.version")).toString();
- runner.setRunnerVersion(runnerVersion);
- return runner;
- }
-}
diff --git a/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java b/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java
new file mode 100644
index 0000000..6f0d851
--- /dev/null
+++ b/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * SonarSource :: IT :: SonarQube Scanner
+ * Copyright (C) 2009 SonarSource
+ * sonarqube@googlegroups.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package com.sonar.runner.it;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import com.sonar.orchestrator.version.Version;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+
+public abstract class ScannerTestCase {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @ClassRule
+ public static Orchestrator orchestrator = SonarScannerTestSuite.ORCHESTRATOR;
+
+ private static Version artifactVersion;
+
+ private static Version artifactVersion() {
+ if (artifactVersion == null) {
+ try (FileInputStream fis = new FileInputStream(new File("../target/maven-archiver/pom.properties"))) {
+ Properties props = new Properties();
+ props.load(fis);
+ artifactVersion = Version.create(props.getProperty("version"));
+ return artifactVersion;
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return artifactVersion;
+ }
+
+ SonarScanner newScanner(File baseDir, String... keyValueProperties) {
+ SonarScanner scannerCli = SonarScanner.create(baseDir, keyValueProperties);
+ scannerCli.setRunnerVersion(artifactVersion().toString());
+ return scannerCli;
+ }
+}
diff --git a/it/src/test/java/com/sonar/runner/it/SonarRunnerTestSuite.java b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
index 6157d7c..8114fcd 100644
--- a/it/src/test/java/com/sonar/runner/it/SonarRunnerTestSuite.java
+++ b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
@@ -19,12 +19,24 @@
*/
package com.sonar.runner.it;
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({JavaTest.class, MultimoduleTest.class, CacheTest.class})
-public class SonarRunnerTestSuite {
+public class SonarScannerTestSuite {
+
+ @ClassRule
+ public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
+ .setOrchestratorProperty("javaVersion", "LATEST_RELEASE")
+ .addPlugin("java")
+ .setOrchestratorProperty("findbugsVersion", "LATEST_RELEASE")
+ .addPlugin("findbugs")
+ .setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE")
+ .addPlugin("javascript")
+ .build();
}
diff --git a/travis.sh b/travis.sh
index c344084..91903a6 100755
--- a/travis.sh
+++ b/travis.sh
@@ -1,55 +1,89 @@
-#!/bin/bash
+#!/bin/bash -v
set -euo pipefail
function installTravisTools {
- mkdir ~/.local
+ mkdir -p ~/.local
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v21 | tar zx --strip-components 1 -C ~/.local
source ~/.local/bin/install
}
-if [ -n "${PR_ANALYSIS:-}" ] && [ "${PR_ANALYSIS}" == true ]
-then
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]
- then
- # For security reasons environment variables are not available on the pull requests
- # coming from outside repositories
- # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
- if [ -n "$SONAR_GITHUB_OAUTH" ]; then
+function strongEcho {
+ echo ""
+ echo "================ $1 ================="
+}
+
+case "$TARGET" in
- # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
- export PATH=$JAVA_HOME/bin:$PATH
+CI)
+ if [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
+ strongEcho 'Build and analyze commit in master'
+ # this commit is master must be built and analyzed (with upload of report)
+ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V
- # PR analysis
- mvn verify sonar:sonar -B -e -V \
- -Dsonar.analysis.mode=issues \
+ # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7
+ export JAVA_HOME=/usr/lib/jvm/java-8-oracle
+ export PATH=$JAVA_HOME/bin:$PATH
+
+ export MAVEN_OPTS="-Xmx1G -Xms128m"
+ mvn sonar:sonar -B -e -V \
+ -Dsonar.host.url=$SONAR_HOST_URL \
+ -Dsonar.login=$SONAR_TOKEN
+
+
+ elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "$GITHUB_TOKEN" ]; then
+ # For security reasons environment variables are not available on the pull requests
+ # coming from outside repositories
+ # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
+ # That's why the analysis does not need to be executed if the variable SONAR_GITHUB_OAUTH is not defined.
+
+ strongEcho 'Build and analyze pull request'
+ # this pull request must be built and analyzed (without upload of report)
+ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V
+
+ # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7
+ export JAVA_HOME=/usr/lib/jvm/java-8-oracle
+ export PATH=$JAVA_HOME/bin:$PATH
+
+ mvn sonar:sonar -B -e -V \
+ -Dsonar.analysis.mode=issues \
-Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
-Dsonar.github.repository=$TRAVIS_REPO_SLUG \
- -Dsonar.github.login=$SONAR_GITHUB_LOGIN \
- -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH \
+ -Dsonar.github.oauth=$GITHUB_TOKEN \
-Dsonar.host.url=$SONAR_HOST_URL \
- -Dsonar.login=$SONAR_LOGIN \
- -Dsonar.password=$SONAR_PASSWD
- fi
- fi
-else
- # Regular CI (use install for ITs)
- mvn install -B -e -V
-fi
+ -Dsonar.login=$SONAR_TOKEN
-if [ -n "${RUN_ITS:-}" ] && [ "${RUN_ITS}" == true ]
-then
- installTravisTools
- build_snapshot "SonarSource/orchestrator"
+ else
+ strongEcho 'Build, no analysis'
+ # Build branch, without any analysis
+ # No need for Maven goal "install" as the generated JAR file does not need to be installed
+ # in Maven local repository
+ mvn verify -Dmaven.test.redirectTestOutputToFile=false -B -e -V
+ fi
+ ;;
+
+IT)
+ installTravisTools
if [ "${SQ_VERSION}" == "DEV" ]
then
build_snapshot "SonarSource/sonarqube"
fi
+ # Need install because ITs will take artifact from local repo
+ mvn install -B -e -V -Dsource.skip=true -Denforcer.skip=true -Danimal.sniffer.skip=true -Dmaven.test.skip=true
+
cd it
- mvn -DsonarRunner.version="2.5-SNAPSHOT" -Dsonar.runtimeVersion=$SQ_VERSION -Dmaven.test.redirectTestOutputToFile=false install
+
+ build_snapshot "SonarSource/orchestrator"
+
+ mvn -Dsonar.runtimeVersion="$SQ_VERSION" -Dmaven.test.redirectTestOutputToFile=false verify
+ ;;
+
+*)
+ echo "Unexpected TARGET value: $TARGET"
+ exit 1
+ ;;
-fi
+esac