2017-01-09 04:49:16 -05:00
|
|
|
/*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2018-12-27 08:17:05 -05:00
|
|
|
properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr: env.BRANCH_NAME=='master'?'5':'1'))])
|
2017-01-09 04:49:16 -05:00
|
|
|
|
2017-12-11 08:42:14 -05:00
|
|
|
def buildOs = 'linux'
|
2018-06-08 15:44:03 -04:00
|
|
|
def buildJdk = '8'
|
2023-01-13 06:00:48 -05:00
|
|
|
def buildMvn = '3.8.x'
|
2022-12-12 17:58:42 -05:00
|
|
|
def runITsOses = ['linux']
|
2022-04-22 12:19:28 -04:00
|
|
|
def runITsJdks = ['8', '11', '17']
|
2023-01-13 06:00:48 -05:00
|
|
|
def runITsMvn = '3.8.x'
|
2018-05-21 13:20:33 -04:00
|
|
|
def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true
|
2017-02-21 12:33:54 -05:00
|
|
|
def tests
|
2017-01-09 04:49:16 -05:00
|
|
|
|
|
|
|
try {
|
2017-03-23 22:25:17 -04:00
|
|
|
|
2021-07-02 12:47:10 -04:00
|
|
|
def osNode = jenkinsEnv.labelForOS(buildOs)
|
2018-07-15 04:35:40 -04:00
|
|
|
node(jenkinsEnv.nodeSelection(osNode)) {
|
2017-01-09 04:49:16 -05:00
|
|
|
dir('build') {
|
2017-03-23 22:25:17 -04:00
|
|
|
stage('Checkout') {
|
|
|
|
checkout scm
|
2017-01-09 04:49:16 -05:00
|
|
|
}
|
2017-03-23 22:25:17 -04:00
|
|
|
|
|
|
|
def WORK_DIR=pwd()
|
2019-05-28 23:13:49 -04:00
|
|
|
def MAVEN_GOAL='verify'
|
|
|
|
|
|
|
|
stage('Configure deploy') {
|
2022-05-31 03:15:06 -04:00
|
|
|
if (env.BRANCH_NAME in ['master', 'maven-3.8.x', 'maven-3.9.x']){
|
2019-05-29 02:19:00 -04:00
|
|
|
MAVEN_GOAL='deploy'
|
2019-05-28 23:13:49 -04:00
|
|
|
}
|
|
|
|
}
|
2017-03-23 22:25:17 -04:00
|
|
|
|
|
|
|
stage('Build / Unit Test') {
|
2017-12-11 08:42:14 -05:00
|
|
|
String jdkName = jenkinsEnv.jdkFromVersion(buildOs, buildJdk)
|
|
|
|
String mvnName = jenkinsEnv.mvnFromVersion(buildOs, buildMvn)
|
2022-12-12 17:58:42 -05:00
|
|
|
try {
|
|
|
|
withEnv(["JAVA_HOME=${ tool "$jdkName" }",
|
|
|
|
"PATH+MAVEN=${ tool "$jdkName" }/bin:${tool "$mvnName"}/bin",
|
|
|
|
"MAVEN_OPTS=-Xms2g -Xmx4g -Djava.awt.headless=true"]) {
|
|
|
|
sh "mvn clean ${MAVEN_GOAL} -B -U -e -fae -V -Dmaven.test.failure.ignore -PversionlessMavenDist -Dmaven.repo.local=${WORK_DIR}/.repository"
|
|
|
|
}
|
|
|
|
} finally {
|
2023-01-13 06:00:48 -05:00
|
|
|
junit testResults: '**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml', allowEmptyResults: true
|
2022-12-12 17:58:42 -05:00
|
|
|
}
|
2017-03-23 22:25:17 -04:00
|
|
|
dir ('apache-maven/target') {
|
2021-10-10 17:35:06 -04:00
|
|
|
stash includes: 'apache-maven-bin.zip', name: 'maven-dist'
|
|
|
|
}
|
2017-01-09 04:49:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-21 13:20:33 -04:00
|
|
|
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}"
|
2017-03-23 22:25:17 -04:00
|
|
|
|
2018-05-21 13:20:33 -04:00
|
|
|
String stageId = "${os}-jdk${jdk}"
|
|
|
|
String stageLabel = "Run ITs ${os.capitalize()} Java ${jdk}"
|
|
|
|
runITsTasks[stageId] = {
|
2018-07-15 04:35:40 -04:00
|
|
|
node(jenkinsEnv.nodeSelection(osLabel)) {
|
2018-05-21 13:20:33 -04:00
|
|
|
stage("${stageLabel}") {
|
2019-07-21 04:20:23 -04:00
|
|
|
echo "NODE_NAME = ${env.NODE_NAME}"
|
2018-05-21 13:20:33 -04:00
|
|
|
// on Windows, need a short path or we hit 256 character limit for paths
|
|
|
|
// using EXECUTOR_NUMBER guarantees that concurrent builds on same agent
|
2018-10-14 18:20:25 -04:00
|
|
|
// will not trample each other plus workaround for JENKINS-52657
|
|
|
|
dir(isUnix() ? 'test' : "c:\\mvn-it-${EXECUTOR_NUMBER}.tmp") {
|
2018-05-21 13:20:33 -04:00
|
|
|
def WORK_DIR=pwd()
|
2022-12-12 17:58:42 -05:00
|
|
|
checkout([$class: 'GitSCM',
|
|
|
|
branches: [[name: "*/master"]],
|
|
|
|
extensions: [[$class: 'CloneOption', depth: 1, noTags: true, shallow: true]],
|
|
|
|
userRemoteConfigs: [[url: 'https://github.com/apache/maven-integration-testing.git']]])
|
2018-05-21 13:20:33 -04:00
|
|
|
if (isUnix()) {
|
2020-05-10 14:00:11 -04:00
|
|
|
sh "rm -rvf $WORK_DIR/dists $WORK_DIR/it-local-repo"
|
2018-05-21 13:20:33 -04:00
|
|
|
} else {
|
|
|
|
bat "if exist it-local-repo rmdir /s /q it-local-repo"
|
2020-05-10 14:00:11 -04:00
|
|
|
bat "if exist dists rmdir /s /q dists"
|
|
|
|
}
|
|
|
|
dir('dists') {
|
|
|
|
unstash 'maven-dist'
|
2018-05-21 13:20:33 -04:00
|
|
|
}
|
2019-07-31 11:22:07 -04:00
|
|
|
try {
|
2022-12-12 17:58:42 -05:00
|
|
|
withEnv(["JAVA_HOME=${ tool "$jdkName" }",
|
|
|
|
"PATH+MAVEN=${ tool "$jdkName" }/bin:${tool "$mvnName"}/bin",
|
|
|
|
"MAVEN_OPTS=-Xms2g -Xmx4g -Djava.awt.headless=true"]) {
|
2023-01-16 09:55:50 -05:00
|
|
|
String cmd = "${runITscommand} -Dmaven.repo.local=$WORK_DIR/it-local-repo -DmavenDistro=$WORK_DIR/dists/apache-maven-bin.zip -Dmaven.test.failure.ignore"
|
2019-07-31 11:22:07 -04:00
|
|
|
|
|
|
|
if (isUnix()) {
|
|
|
|
sh 'df -hT'
|
|
|
|
sh "${cmd}"
|
|
|
|
} else {
|
|
|
|
bat 'wmic logicaldisk get size,freespace,caption'
|
|
|
|
bat "${cmd}"
|
|
|
|
}
|
2018-05-21 13:20:33 -04:00
|
|
|
}
|
2019-07-31 11:22:07 -04:00
|
|
|
} finally {
|
2023-01-13 06:00:48 -05:00
|
|
|
// in ITs test we need only reports from test itself
|
|
|
|
// test projects can contain reports with tested failed builds
|
|
|
|
junit testResults: '**/core-it-suite/target/surefire-reports/*.xml,**/core-it-support/**/target/surefire-reports/*.xml', allowEmptyResults: true
|
2019-07-31 11:22:07 -04:00
|
|
|
archiveDirs(stageId, ['core-it-suite-logs':'core-it-suite/target/test-classes',
|
|
|
|
'core-it-suite-reports':'core-it-suite/target/surefire-reports'])
|
|
|
|
deleteDir() // clean up after ourselves to reduce disk space
|
2018-05-21 13:20:33 -04:00
|
|
|
}
|
2017-12-11 08:42:14 -05:00
|
|
|
}
|
2017-01-09 04:49:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-21 13:20:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// run the parallel ITs
|
|
|
|
parallel(runITsTasks)
|
2017-03-23 22:25:17 -04:00
|
|
|
|
2017-12-11 08:42:14 -05:00
|
|
|
// JENKINS-34376 seems to make it hard to detect the aborted builds
|
|
|
|
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
|
2019-01-23 18:12:00 -05:00
|
|
|
echo "[FAILURE-002] FlowInterruptedException ${e}"
|
2017-12-11 08:42:14 -05:00
|
|
|
// this ambiguous condition means a user probably aborted
|
|
|
|
if (e.causes.size() == 0) {
|
|
|
|
currentBuild.result = "ABORTED"
|
|
|
|
} else {
|
|
|
|
currentBuild.result = "FAILURE"
|
|
|
|
}
|
|
|
|
throw e
|
|
|
|
} catch (hudson.AbortException e) {
|
2019-01-23 18:12:00 -05:00
|
|
|
echo "[FAILURE-003] AbortException ${e}"
|
2017-12-11 08:42:14 -05:00
|
|
|
// this ambiguous condition means during a shell step, user probably aborted
|
|
|
|
if (e.getMessage().contains('script returned exit code 143')) {
|
|
|
|
currentBuild.result = "ABORTED"
|
|
|
|
} else {
|
|
|
|
currentBuild.result = "FAILURE"
|
2017-01-09 04:49:16 -05:00
|
|
|
}
|
2017-12-11 08:42:14 -05:00
|
|
|
throw e
|
|
|
|
} catch (InterruptedException e) {
|
2019-01-23 18:12:00 -05:00
|
|
|
echo "[FAILURE-004] ${e}"
|
2017-12-11 08:42:14 -05:00
|
|
|
currentBuild.result = "ABORTED"
|
|
|
|
throw e
|
|
|
|
} catch (Throwable e) {
|
2019-01-23 18:12:00 -05:00
|
|
|
echo "[FAILURE-001] ${e}"
|
2017-12-11 08:42:14 -05:00
|
|
|
currentBuild.result = "FAILURE"
|
|
|
|
throw e
|
|
|
|
} finally {
|
|
|
|
// notify completion
|
|
|
|
stage("Notifications") {
|
2021-07-02 12:47:10 -04:00
|
|
|
jenkinsNotify()
|
|
|
|
}
|
2017-01-09 04:49:16 -05:00
|
|
|
}
|
2019-07-31 11:22:07 -04:00
|
|
|
|
|
|
|
def archiveDirs(stageId, archives) {
|
|
|
|
archives.each { archivePrefix, pathToContent ->
|
|
|
|
if (fileExists(pathToContent)) {
|
|
|
|
zip(zipFile: "${archivePrefix}-${stageId}.zip", dir: pathToContent, archive: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|