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 12:07:42 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 81f77051d9344ebc59de270eab3055a9a27807db
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 | 146 +++++++++++++++---------------------------------------------
 1 file changed, 35 insertions(+), 111 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 6e99928..bc7bd01 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -59,70 +59,27 @@ node(jenkinsEnv.labelForOS(buildOs)) {
     }
 }
 
+def runCoreITs(String os, String version) {
+    node(jenkinsEnv.labelForOS(os)) {
+        stage ("Run ITs ${os} Java ${version}') {
+            String jdkName = jenkinsEnv.jdkFromVersion(os, version)
+            String mvnName = jenkinsEnv.mvnFromVersion(os, buildMvn)
+            String command = "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true"
 
-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"
-                    }
-                    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)
-
+            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 "${command} -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
@@ -135,60 +92,27 @@ parallel linuxJava7:{
                     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"
+                        bat "${command} -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
-                }
-            }
-        }
+parallel linuxJava7:{
+        runCoreITs('linux', '7')
+    },linuxJava8: {
+        runCoreITs('linux', '8')
+    },linuxJava9: {
+        runCoreITs('linux', '9')
+    }, winJava7: {
+        runCoreITs('windows', '7')
+    }, winJava8: {
+        runCoreITs('windows', '8')
     }, 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
-                }
-            }
-        }
+        runCoreITs('windows', '9')
     }
 
 // JENKINS-34376 seems to make it hard to detect the aborted builds

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

Mime
View raw message