From 23615069db2863f45dba4b9df50b30cf6fb7b792 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 25 Jun 2019 16:33:56 +0200 Subject: SQSCANNER-60 Upgrade embedded JRE to 11 Move QA to use Jenkinsfile --- Jenkinsfile | 136 +++++++++++++++++++++ .../com/sonarsource/scanner/it/ScannerTest.java | 17 +-- pom.xml | 80 ++++-------- 3 files changed, 169 insertions(+), 64 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a01e687 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,136 @@ +@Library('SonarSource@2.2') _ +pipeline { + agent { + label 'linux' + } + parameters { + string(name: 'GIT_SHA1', description: 'Git SHA1 (provided by travisci hook job)') + string(name: 'CI_BUILD_NAME', defaultValue: 'sonar-scanner-cli', description: 'Build Name (provided by travisci hook job)') + string(name: 'CI_BUILD_NUMBER', description: 'Build Number (provided by travisci hook job)') + string(name: 'GITHUB_BRANCH', defaultValue: 'master', description: 'Git branch (provided by travisci hook job)') + string(name: 'GITHUB_REPOSITORY_OWNER', defaultValue: 'SonarSource', description: 'Github repository owner(provided by travisci hook job)') + } + environment { + SONARSOURCE_QA = 'true' + MAVEN_TOOL = 'Maven 3.6.x' + JDK_VERSION = 'Java 11' + } + stages { + stage('Notify') { + steps { + sendAllNotificationQaStarted() + } + } + stage('QA') { + parallel { + stage('DOGFOOD/linux') { + agent { + label 'linux' + } + steps { + runITs("DOGFOOD") + } + } + stage('LATEST_RELEASE[6.7]/linux') { + agent { + label 'linux' + } + environment { + JDK_VERSION = 'Java 8' + } + steps { + runITs("LATEST_RELEASE[6.7]") + } + } + stage('LATEST_RELEASE/linux') { + agent { + label 'linux' + } + steps { + runITs("LATEST_RELEASE") + } + } + + stage('DOGFOOD/windows') { + agent { + label 'windows' + } + steps { + runITs("DOGFOOD") + } + } + stage('LATEST_RELEASE[6.7]/windows') { + agent { + label 'windows' + } + environment { + JDK_VERSION = 'Java 8' + } + steps { + runITs("LATEST_RELEASE[6.7]") + } + } + stage('LATEST_RELEASE/windows') { + agent { + label 'windows' + } + steps { + runITs("LATEST_RELEASE") + } + } + + stage('DOGFOOD/macosx') { + agent { + label 'macosx' + } + steps { + runITs("DOGFOOD") + } + } + stage('LATEST_RELEASE[6.7]/macosx') { + agent { + label 'macosx' + } + environment { + JDK_VERSION = 'Java 8' + } + steps { + runITs("LATEST_RELEASE[6.7]") + } + } + stage('LATEST_RELEASE/macosx') { + agent { + label 'macosx' + } + steps { + runITs("LATEST_RELEASE") + } + } + } + post { + always { + sendAllNotificationQaResult() + } + } + + } + stage('Promote') { + steps { + repoxPromoteBuild() + } + post { + always { + sendAllNotificationPromote() + } + } + } + } +} + +def runITs(SQ_VERSION) { + withMaven(maven: MAVEN_TOOL) { + dir("it") { + runMavenOrch(JDK_VERSION,"verify -Dsonar.runtimeVersion=$SQ_VERSION -U") + } + } +} \ No newline at end of file diff --git a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java index fa147ac..f003df2 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java @@ -25,7 +25,6 @@ import java.io.File; import java.io.IOException; import java.util.Map; import java.util.stream.Collectors; -import org.assertj.core.api.Condition; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -188,19 +187,15 @@ public class ScannerTest extends ScannerTestCase { } @Test - public void verify_env_variable() { + public void verify_scanner_opts_env_variable_passed_as_jvm_argument() { SonarScanner build = newScanner(new File("projects/simple-sample")) - .setEnvironmentVariable("SONAR_SCANNER_OPTS", "-Xmx2m"); + .setEnvironmentVariable("SONAR_SCANNER_OPTS", "-Xmx1k"); BuildResult executeBuild = orchestrator.executeBuildQuietly(build); - assertThat(executeBuild.getStatus()).isNotEqualTo(0); + assertThat(executeBuild.getLastStatus()).isNotEqualTo(0); String logs = executeBuild.getLogs(); - assertThat(logs).is(new Condition("Contain error message about OOM") { - @Override - public boolean matches(String value) { - return value.contains("java.lang.OutOfMemoryError") - || value.contains("GC overhead limit exceeded") || value.contains("Java heap space"); - } - }); + assertThat(logs).contains("Error occurred during initialization of VM"); + // Not the same message with JRE 8 and 11 + assertThat(logs).containsPattern("Too small (initial|maximum) heap"); } } diff --git a/pom.xml b/pom.xml index ce6802e..ce5b040 100644 --- a/pom.xml +++ b/pom.xml @@ -48,10 +48,9 @@ ${project.build.directory}/unpack ${project.build.finalName}.jar - 8u202 - jre1.8.0_202 - jre1.8.0_202 - jre1.8.0_202.jre/Contents/Home + jdk-11.0.3+7-jre + jdk-11.0.3+7-jre + jdk-11.0.3+7-jre/Contents/Home ${project.groupId}:${project.artifactId}:zip,${project.groupId}:${project.artifactId}:zip:linux,${project.groupId}:${project.artifactId}:zip:windows,${project.groupId}:${project.artifactId}:zip:macosx @@ -207,33 +206,25 @@ - org.apache.maven.plugins - maven-dependency-plugin - 3.0.0 + com.googlecode.maven-download-plugin + download-maven-plugin + 1.4.2 unpack-linux package - unpack + wget - - - com.oracle - jre - ${jre.version} - linux-x64 - tar.gz - true - - + https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_linux_hotspot_11.0.3_7.tar.gz + true ${unpack.dir}/linux + b7232a3c75a8c4e67f51bd95c8441026b2bfef29cc779768a5f2d300208dc569d672402e06a2d6c6f512450723bc0631c5a18cde80cbc1ec2028c123607df30f - maven-assembly-plugin @@ -265,33 +256,25 @@ - org.apache.maven.plugins - maven-dependency-plugin - 3.0.0 + com.googlecode.maven-download-plugin + download-maven-plugin + 1.4.2 unpack-windows package - unpack + wget - - - com.oracle - jre - ${jre.version} - windows-x64 - tar.gz - true - - + https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_windows_hotspot_11.0.3_7.zip + true ${unpack.dir}/windows + 370100688282a5c43fe0ac736980eeff64cf212a0fb573181fff8039c121097cbbbd540a652cc6d17397789b894c820b802b875bbd1743eb2b8469009d5fa8f9 - maven-assembly-plugin @@ -317,39 +300,30 @@ - dist-macosx - org.apache.maven.plugins - maven-dependency-plugin - 3.0.0 + com.googlecode.maven-download-plugin + download-maven-plugin + 1.4.2 unpack-macosx package - unpack + wget + + https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_mac_hotspot_11.0.3_7.tar.gz + true + ${unpack.dir}/macosx + 5995c18fa0f2ef9d74c9fb38401d497b16e78b57eaf5b795f19724a8c1f6609add96355627b8cb0564d29421a63d830df11f932b76436a713a535a1253e745e6 + - - - - com.oracle - jre - ${jre.version} - macosx-x64 - tar.gz - true - - - ${unpack.dir}/macosx - - maven-assembly-plugin -- cgit v1.2.3