diff options
author | Julien HENRY <henryju@yahoo.fr> | 2016-07-05 12:22:46 +0200 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2016-07-05 12:22:46 +0200 |
commit | 76530d18f1797b2c752f280952f8592253c245a7 (patch) | |
tree | 3593d05828935fbdc914a48b851ee2b5f5b3b2e0 /it | |
parent | 97df742be527eee859b83441e2cc645f19326f83 (diff) | |
download | sonar-scanner-cli-76530d18f1797b2c752f280952f8592253c245a7.tar.gz sonar-scanner-cli-76530d18f1797b2c752f280952f8592253c245a7.zip |
Try to fix ITs on QA
Diffstat (limited to 'it')
-rw-r--r-- | it/pom.xml | 68 | ||||
-rw-r--r-- | it/src/test/java/com/sonar/runner/it/ScannerTestCase.java | 25 |
2 files changed, 81 insertions, 12 deletions
@@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -52,10 +52,10 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <version>2.1.0</version> - </dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>2.1.0</version> + </dependency> </dependencies> <build> @@ -65,6 +65,9 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> + <systemProperties> + <scannerVersion>${scanner.version}</scannerVersion> + </systemProperties> <includes> <include>**/SonarScannerTestSuite.java</include> </includes> @@ -74,4 +77,59 @@ </pluginManagement> </build> + <profiles> + <profile> + <id>download-qa-artifacts</id> + <activation> + <property> + <name>env.CI_BUILD_NUMBER</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>groovy-maven-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <id>compute-qa-version</id> + <phase>initialize</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <source><![CDATA[ + String pom = new File(project.basedir, '../pom.xml').getText('UTF-8') + def matcher = pom =~ /(?s).*<version>(.*?)-SNAPSHOT<\/version>.*/ + assert matcher.matches() + project.properties['scanner.version'] = matcher[0][1] + '-build' + System.getenv()['CI_BUILD_NUMBER'] + ]]> + </source> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.10</version> + <executions> + <execution> + <id>download-qa-scanner</id> + <phase>initialize</phase> + <goals> + <goal>get</goal> + </goals> + <configuration> + <artifact>org.sonarsource.scanner.cli:sonar-scanner-cli:${scanner.version}:zip</artifact> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java b/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java index 0f8d7fa..4562a42 100644 --- a/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java +++ b/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java @@ -26,12 +26,17 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; +import org.apache.commons.lang.StringUtils; import org.junit.ClassRule; import org.junit.Rule; import org.junit.rules.ExpectedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class ScannerTestCase { + private static final Logger LOG = LoggerFactory.getLogger(ScannerTestCase.class); + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -42,13 +47,19 @@ public abstract class ScannerTestCase { 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); + String scannerVersion = System.getProperty("scanner.version"); + if (StringUtils.isNotBlank(scannerVersion)) { + LOG.info("Use provided Scanner version: " + scannerVersion); + artifactVersion = Version.create(scannerVersion); + } else { + 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; |