maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject [maven] 01/01: created a function to run CoreITs and avoid copy/paste
Date Mon, 21 May 2018 15:48:11 GMT
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-6364
in repository https://gitbox.apache.org/repos/asf/maven.git

commit c904f5f695f264e9a573885b8ac63c179d0d53b4
Author: Hervé Boutemy <hboutemy@apache.org>
AuthorDate: Mon May 21 14:06:14 2018 +0200

    created a function to run CoreITs and avoid copy/paste
---
 Jenkinsfile | 175 +++++++++++++++++-------------------------------------------
 1 file changed, 49 insertions(+), 126 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 6e99928..2d89bc6 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -22,8 +22,11 @@ properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr:
e
 def buildOs = 'linux'
 def buildJdk = '8'
 def buildMvn = '3.5.0'
+def runITsOses = ['linux', 'windows']
+def runITsJdks = ['7', '8', '9']
+def runITsMvn = '3.5.0'
+def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V -Dmaven.test.failure.ignore=true"
// -DmavenDistro=...
 def tests
-def CORE_IT_PROFILES='run-its,embedded'
 
 try {
 
@@ -59,137 +62,57 @@ node(jenkinsEnv.labelForOS(buildOs)) {
     }
 }
 
+Map runITsTasks = [:]
+for (String os in runITsOses) {
+    for (def jdk in runITsJdks) {
+        String osLabel = jenkinsEnv.labelForOS(os);
+        String jdkName = jenkinsEnv.jdkFromVersion(os, "${jdk}")
+        String mvnName = jenkinsEnv.mvnFromVersion(os, "${runITsMvn}")
+        echo "OS: ${os} JDK: ${jdk} => Label: ${osLabel} JDK: ${jdkName}"
 
-parallel linuxJava7:{
-        node(jenkinsEnv.labelForOS('linux')) {
-            stage ('Run ITs Linux Java 7') {
-                String jdkName = jenkinsEnv.jdkFromVersion('linux', '7')
-                String mvnName = jenkinsEnv.mvnFromVersion('linux', buildMvn)
-                dir('test') {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        sh "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
+        String stageId = "${os}-jdk${jdk}"
+        runITsTasks[stageId] = {
+            node(osLabel) {
+                stage("Run ITs ${os.capitalize()} Java ${jdk}") {
+                    if (!(os == 'windows')) {
+                        dir('test') {
+                            def WORK_DIR=pwd()
+                            checkout tests
+                            sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo"
+                            unstash 'dist'
+                            withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
+                                junitPublisher(ignoreAttachments: false)
+                            ]) {
+                                sh "${runITscommand} -DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
+                            }
+                            deleteDir() // clean up after ourselves to reduce disk space
+                        }
+                    } else {
+                        // need a short path or we hit 256 character limit for paths
+                        // using EXECUTOR_NUMBER guarantees that concurrent builds on same
agent
+                        // will not trample each other
+                        dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") {
+                            def WORK_DIR=pwd()
+                            checkout tests
+                            bat "if exist it-local-repo rmdir /s /q it-local-repo"
+                            bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip"
+                            unstash 'dist'
+                            withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
+                                junitPublisher(ignoreAttachments: false)
+                            ]) {
+                                bat "${runITscommand} -DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
+                            }
+                            deleteDir() // clean up after ourselves to reduce disk space
+                        }
                     }
-                    deleteDir() // clean up after ourselves to reduce disk space
-                }
-            }
-        }
-    },linuxJava8: {
-        node(jenkinsEnv.labelForOS('linux')) {
-            stage ('Run ITs Linux Java 8') {
-                String jdkName = jenkinsEnv.jdkFromVersion('linux', '8')
-                String mvnName = jenkinsEnv.mvnFromVersion('linux', buildMvn)
-                dir('test') {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        sh "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
-                    }
-                    deleteDir() // clean up after ourselves to reduce disk space
-                }
-            }
-        }
-    },linuxJava9: {
-        node(jenkinsEnv.labelForOS('linux')) {
-            stage ('Linux Java 9') {
-                String jdkName = jenkinsEnv.jdkFromVersion('linux', '9')
-                String mvnName = jenkinsEnv.mvnFromVersion('linux', buildMvn)
-                dir('test') {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        sh "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
-                    }
-                    deleteDir() // clean up after ourselves to reduce disk space
-                }
-            }
-        }
-    }, winJava7: {
-        node(jenkinsEnv.labelForOS('windows')) {
-            stage ('Run ITs Windows Java 7') {
-                String jdkName = jenkinsEnv.jdkFromVersion('windows', '7')
-                String mvnName = jenkinsEnv.mvnFromVersion('windows', buildMvn)
-
-                // need a short path or we hit 256 character limit for paths
-                // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent
-                // will not trample each other
-                dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    bat "if exist it-local-repo rmdir /s /q it-local-repo"
-                    bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        bat "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
-                    }
-                    deleteDir() // clean up after ourselves to reduce disk space
-                }
-            }
-        }
-    }, winJava8: {
-        node(jenkinsEnv.labelForOS('windows')) {
-            stage ('Run ITs Windows Java 8') {
-                String jdkName = jenkinsEnv.jdkFromVersion('windows', '8')
-                String mvnName = jenkinsEnv.mvnFromVersion('windows', buildMvn)
-
-                // need a short path or we hit 256 character limit for paths
-                // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent
-                // will not trample each other
-                dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    bat "if exist it-local-repo rmdir /s /q it-local-repo"
-                    bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        bat "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
-                    }
-                    deleteDir() // clean up after ourselves to reduce disk space
-                }
-            }
-        }
-    }, winJava9: {
-        node(jenkinsEnv.labelForOS('windows')) {
-            stage ('Windows Java 9') {
-                String jdkName = jenkinsEnv.jdkFromVersion('windows', '9')
-                String mvnName = jenkinsEnv.mvnFromVersion('windows', buildMvn)
-
-                // need a short path or we hit 256 character limit for paths
-                // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent
-                // will not trample each other
-                dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") {
-                    def WORK_DIR=pwd()
-                    checkout tests
-                    bat "if exist it-local-repo rmdir /s /q it-local-repo"
-                    bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip"
-                    unstash 'dist'
-                    withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo",
options:[
-                        junitPublisher(ignoreAttachments: false)
-                    ]) {
-                        bat "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true
-DmavenDistro=$WORK_DIR/apache-maven-dist.zip"
-                    }
-                    deleteDir() // clean up after ourselves to reduce disk space
                 }
             }
         }
     }
+}
+
+// run the parallel ITs
+parallel(runITsTasks)
 
 // JENKINS-34376 seems to make it hard to detect the aborted builds
 } catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {

-- 
To stop receiving notification emails like this one, please contact
hboutemy@apache.org.

Mime
View raw message