Repository: maven-surefire Updated Branches: refs/heads/SUREFIRE-1489 314870f98 -> 6ae2fd7ec (forced update)
[SUREFIRE-1489] Implement lock() and zip() in jenkinsfile Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/6ae2fd7e Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/6ae2fd7e Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/6ae2fd7e Branch: refs/heads/SUREFIRE-1489 Commit: 6ae2fd7ecf16d094f200f0f6af7d4e5dc9180a7d Parents: d46556f Author: Tibor17 <tibordig...@apache.org> Authored: Fri Feb 23 05:39:47 2018 +0100 Committer: Tibor17 <tibordig...@apache.org> Committed: Sat Feb 24 17:34:49 2018 +0100 ---------------------------------------------------------------------- Jenkinsfile | 144 +++++++++++++++------------ pom.xml | 8 ++ surefire-its/pom.xml | 3 + surefire-its/src/test/resources/pom.xml | 6 ++ 4 files changed, 95 insertions(+), 66 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6ae2fd7e/Jenkinsfile ---------------------------------------------------------------------- diff --git a/Jenkinsfile b/Jenkinsfile index 822bbc1..201d0ec 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,42 +26,44 @@ properties( ] ) -final String NIX_LABEL = 'ubuntu-1||ubuntu-4||ubuntu-6||H19||H20' -final String WIN_LABEL = 'windows-2016-1' - final def oses = ['linux', 'windows'] final def mavens = ['3.2.x', '3.3.x', '3.5.x'] // env.BRANCH_NAME == 'master' ? ['3.2.x', '3.3.x', '3.5.x'] : ['3.5.x'] -final def jdks = ['7', '8', '9', '10'] // env.BRANCH_NAME == 'master' ? ['7', '8', '9', '10'] : ['10'] +final def jdks = [7, 8, 9, 10] // env.BRANCH_NAME == 'master' ? [7, 8, 9, 10] : [9, 10] -final def cmd = ['mvn'] -final def options = ['-e', '-V', '-nsu', '-P', 'run-its'] +final def options = ['-e', '-V', '-B', '-nsu'] +final def optionsIT = ['-pl', 'maven-failsafe-plugin', '-P', 'run-its'] final def goals = ['clean', 'install', 'jacoco:report'] final Map stages = [:] oses.eachWithIndex { os, indexOfOs -> - stages[os] = { - mavens.eachWithIndex { maven, indexOfMaven -> - jdks.eachWithIndex { jdk, indexOfJdk -> - final String label = jenkinsEnv.labelForOS(os); - final String jdkTestName = jenkinsEnv.jdkFromVersion(os, jdk) - final String jdkName = jenkinsEnv.jdkFromVersion(os, '8') - final String mvnName = jenkinsEnv.mvnFromVersion(os, maven) - final String stageKey = "${os}-jdk${jdk}-maven${maven}" + mavens.eachWithIndex { maven, indexOfMaven -> + jdks.eachWithIndex { jdk, indexOfJdk -> + final String label = jenkinsEnv.labelForOS(os); + final String jdkTestName = jenkinsEnv.jdkFromVersion(os, jdk.toString()) + final String jdkName = jenkinsEnv.jdkFromVersion(os, '8') + final String mvnName = jenkinsEnv.mvnFromVersion(os, maven) + final String stageKey = "${os}-jdk${jdk}-maven${maven}" - if (label == null || jdkTestName == null || mvnName == null) { - println "Skipping ${stageKey} as unsupported by Jenkins Environment." - return; - } + def mavenOpts = '-server -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseNUMA \ +-Xms64m -Djava.awt.headless=true' + if (jdk > 7) { + mavenOpts += ' -XX:+UseStringDeduplication' + } + mavenOpts += (os == 'linux' ? ' -Xmx1g' : ' -Xmx256m') - println "${stageKey} ==> Label: ${label}, JDK: ${jdkTestName}, Maven: ${mvnName}." - if (os == 'windows') { - node(WIN_LABEL) { - buildProcess(stageKey, jdkName, jdkTestName, mvnName, cmd, options, goals, false) - } - } else { - node(NIX_LABEL) { - boolean makeReports = indexOfMaven == mavens.size() - 1 && jdk == '9' - buildProcess(stageKey, jdkName, jdkTestName, mvnName, cmd, options, goals, makeReports) + if (label == null || jdkTestName == null || mvnName == null) { + println "Skipping ${stageKey} as unsupported by Jenkins Environment." + return; + } + + println "${stageKey} ==> Label: ${label}, JDK: ${jdkTestName}, Maven: ${mvnName}." + + stages[stageKey] = { + node(label) { + timestamps { + //https://github.com/jacoco/jacoco/issues/629 + def boolean makeReports = os == 'linux' && indexOfMaven == mavens.size() - 1 && jdk == 9 + buildProcess(stageKey, jdkName, jdkTestName, mvnName, goals, options, optionsIT, mavenOpts, makeReports) } } } @@ -69,7 +71,7 @@ oses.eachWithIndex { os, indexOfOs -> } } -timeout(time: 24, unit: 'HOURS') { +timeout(time: 10, unit: 'HOURS') { try { parallel(stages) // JENKINS-34376 seems to make it hard to detect the aborted builds @@ -102,7 +104,7 @@ timeout(time: 24, unit: 'HOURS') { } } -def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvnName, cmd, options, goals, boolean makeReports) { +def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvnName, goals, options, optionsIT, mavenOpts, boolean makeReports) { cleanWs() try { if (isUnix()) { @@ -116,33 +118,34 @@ def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvn } println "Maven Local Repository = ${mvnLocalRepoDir}." - assert mvnLocalRepoDir != null: 'Local Maven Repository is undefined.' + assert mvnLocalRepoDir != null : 'Local Maven Repository is undefined.' stage("checkout ${stageKey}") { checkout scm } def jdkTestHome = resolveToolNameToJavaPath(jdkTestName, mvnName) - //https://github.com/jacoco/jacoco/issues/629 - def properties = ["\"-Djdk.home=${jdkTestHome}\"", "-Djacoco.skip=${!makeReports}"] - println("Setting JDK for testing ${properties[0]}") - def mavenOpts = '-server -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xms64m -Xmx1g -Djava.awt.headless=true' + def script = ['mvn'] + goals + options stage("build ${stageKey}") { - withMaven(jdk: jdkName, maven: mvnName, - mavenLocalRepo: mvnLocalRepoDir, mavenOpts: mavenOpts, - options: [ - findbugsPublisher(disabled: !makeReports), - openTasksPublisher(disabled: true), - junitPublisher(disabled: true), - artifactsPublisher(disabled: true), - invokerPublisher(disabled: true) - ]) { - def script = cmd + options + goals + properties + /*mvn(mvnName, script, mavenOpts, mvnLocalRepoDir, jdkName, jdkTestHome, makeReports) + lock('maven-surefire-lock') { + timeout(time: 2, unit: 'MINUTES') { + mvn(mvnName, script + optionsIT, mavenOpts, mvnLocalRepoDir, jdkName, jdkTestHome, false) + } + }*/ + withEnv(["JAVA_HOME=${tool(jdkName)}", "JAVA_HOME_IT=${tool(jdkTestName)}", "PATH+MAVEN=${tool(mvnName)}/bin:${env.JAVA_HOME}/bin"]) { + echo 'Lets print env vars:' if (isUnix()) { - sh script.join(' ') + sh 'echo $JAVA_HOME' + sh 'echo JAVA_HOME_IT' + sh 'echo $M2_HOME' + sh 'mvn -V -fn -nsu' } else { - bat script.join(' ') + bat 'echo %JAVA_HOME%' + bat 'echo %JAVA_HOME_IT%' + bat 'echo %M2_HOME%' + bat 'mvn -V -fn -nsu' } } } @@ -167,28 +170,15 @@ def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvn } } - if (isUnix()) { - if (fileExists('maven-failsafe-plugin/target/it')) { - sh "tar czf failsafe-its-${stageKey}.tgz maven-failsafe-plugin/target/it" - } - - if (fileExists('surefire-its/target')) { - sh "tar czf surefire-its-${stageKey}.tgz surefire-its/target" - } -// println(readFile('target/rat.txt')) -// Wait for INFRA installation of Pipeline Utils, use fileExists() -// if (fileExists('maven-failsafe-plugin/target/it')) { -// zip(zipFile: "it--maven-failsafe-plugin--${stageKey}.zip", dir: 'maven-failsafe-plugin/target/it', archive: true) -// } -// -// if (fileExists('surefire-its/target')) { -// zip(zipFile: "it--surefire-its--${stageKey}.zip", dir: 'surefire-its/target', archive: true) -// } -// -// archiveArtifacts(artifacts: 'surefire-its/target/**/log.txt', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: false) + if (fileExists('maven-failsafe-plugin/target/it')) { + zip(zipFile: "it--maven-failsafe-plugin--${stageKey}.zip", dir: 'maven-failsafe-plugin/target/it', archive: true) + } - archive includes: '*.tgz' + if (fileExists('surefire-its/target')) { + zip(zipFile: "it--surefire-its--${stageKey}.zip", dir: 'surefire-its/target', archive: true) } + + archiveArtifacts(artifacts: '*.zip', allowEmptyArchive: true, onlyIfSuccessful: false) } stage("cleanup ${stageKey}") { @@ -198,6 +188,27 @@ def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvn } } +def mvn(mvnName, cmd, mavenOpts, mvnLocalRepoDir, jdkName, jdkTestHome, boolean makeReports) { + withMaven(jdk: jdkName, maven: mvnName, + mavenLocalRepo: mvnLocalRepoDir, mavenOpts: mavenOpts, + options: [ + findbugsPublisher(disabled: !makeReports), + openTasksPublisher(disabled: true), + junitPublisher(disabled: true), + artifactsPublisher(disabled: true), + invokerPublisher(disabled: true) + ]) { + def properties = ["\"-Djdk.home=${jdkTestHome}\"", "-Djacoco.skip=${!makeReports}"] + println "Setting JDK for testing ${properties[0]}" + cmd = cmd + properties + if (isUnix()) { + sh cmd.join(' ') + } else { + bat cmd.join(' ') + } + } +} + /** * It is used instead of tool(${jdkTestName}). */ @@ -205,6 +216,7 @@ def resolveToolNameToJavaPath(jdkToolName, mvnName) { def javaHome = null try { withMaven(jdk: jdkToolName, maven: mvnName) { + //noinspection GrReassignedInClosureLocalVar javaHome = isUnix() ? sh(script: 'echo -en $JAVA_HOME', returnStdout: true) : bat(script: '@echo %JAVA_HOME%', returnStdout: true) } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6ae2fd7e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 4a768a5..1f10570 100644 --- a/pom.xml +++ b/pom.xml @@ -438,6 +438,9 @@ <useFile>false</useFile> <redirectTestOutputToFile>false</redirectTestOutputToFile> <jvm>${jdk.home}/bin/java</jvm> + <environmentVariables> + <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED> + </environmentVariables> </configuration> </plugin> <plugin> @@ -462,6 +465,11 @@ <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.0.1</version> + <configuration> + <environmentVariables> + <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED> + </environmentVariables> + </configuration> </plugin> <plugin> <groupId>org.jacoco</groupId> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6ae2fd7e/surefire-its/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml index bc097db..5462020 100644 --- a/surefire-its/pom.xml +++ b/surefire-its/pom.xml @@ -129,6 +129,9 @@ <jacoco.agent>${jacoco-it.agent}</jacoco.agent> </systemPropertyVariables> <redirectTestOutputToFile>false</redirectTestOutputToFile> + <environmentVariables> + <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED> + </environmentVariables> </configuration> <dependencies> <dependency> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6ae2fd7e/surefire-its/src/test/resources/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/pom.xml b/surefire-its/src/test/resources/pom.xml index e01ed4c..91cdbbe 100644 --- a/surefire-its/src/test/resources/pom.xml +++ b/surefire-its/src/test/resources/pom.xml @@ -21,6 +21,9 @@ <version>${surefire.version}</version> <configuration> <forkMode>never</forkMode> + <environmentVariables> + <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED> + </environmentVariables> </configuration> </plugin> <plugin> @@ -28,6 +31,9 @@ <version>${surefire.version}</version> <configuration> <forkMode>never</forkMode> + <environmentVariables> + <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED> + </environmentVariables> </configuration> </plugin> <plugin>