From 93ab29b86f27dd74ffe9fa124d551a6f1d3f10a9 Mon Sep 17 00:00:00 2001 From: Lan Xia Date: Wed, 31 May 2023 17:38:54 -0400 Subject: [PATCH] Trigger rerun builds without holding an extra machine (#4593) Signed-off-by: Lan Xia --- buildenv/jenkins/JenkinsfileBase | 16 +++++++--------- buildenv/jenkins/openjdk_tests | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/buildenv/jenkins/JenkinsfileBase b/buildenv/jenkins/JenkinsfileBase index 0400ad854f..4fb124b799 100644 --- a/buildenv/jenkins/JenkinsfileBase +++ b/buildenv/jenkins/JenkinsfileBase @@ -82,6 +82,7 @@ def setupEnv() { env.DYNAMIC_COMPILE=params.DYNAMIC_COMPILE ? params.DYNAMIC_COMPILE : false env.USE_JRE=params.USE_JRE ? params.USE_JRE : false env.RERUN_LINK = "" + env.FAILED_TESTS = "" env.FAILED_TEST_TARGET = "" env.CUSTOM_TARGET_KEY_VALUE ="" env.DOCKER_REGISTRY_URL = params.DOCKER_REGISTRY_URL ? params.DOCKER_REGISTRY_URL : "" @@ -860,8 +861,7 @@ def post(output_name) { uploadToArtifactory(pattern) } } - String failedTests = addFailedTestsGrinderLink() - triggerRerunJob(failedTests) + addFailedTestsGrinderLink() } } @@ -1154,6 +1154,7 @@ def addFailedTestsGrinderLink(paths=""){ } if (failedTestList) { String failedTests = failedTestList.substring(0, failedTestList.length() - 1) + env.FAILED_TESTS= failedTests ?: "" failedTestList = "testList+TESTLIST=" + failedTests String url = env.RERUN_LINK def failedTestUrl = url.replace(env.FAILED_TEST_TARGET, "TARGET=$failedTestList") @@ -1174,9 +1175,7 @@ def addFailedTestsGrinderLink(paths=""){ echo "Rerun failed ${target} test cases in Grinder with ${target}_custom target: ${customURL}" currentBuild.description += "
Rerun failed ${target} test cases in Grinder with ${target}_custom target" } - return failedTests; } - return null; } } @@ -1204,11 +1203,11 @@ def generateJob (newJobs, childTest, testJobName) { } } } -def triggerRerunJob (failedTests) { +def triggerRerunJob () { // if the JOB_NAME contains _rerun or _testList_, we will not trigger rerun job if (!JOB_NAME.contains("_rerun") && !JOB_NAME.contains("_testList_") && !JOB_NAME.contains("_iteration_")) { int rerunIterations = params.RERUN_ITERATIONS ? params.RERUN_ITERATIONS.toInteger() : 0 - if (rerunIterations > 0 && failedTests) { + if (rerunIterations > 0 && env.FAILED_TESTS?.trim()) { stage('Rerun') { def rerunJobName = "${JOB_NAME}_rerun" def newJobs = [:] @@ -1221,7 +1220,7 @@ def triggerRerunJob (failedTests) { // set PARALLEL, NUM_MACHINES and TEST_TIME to default values // set TARGET to failed tests and set ITERATIONS to rerunIterations if (param.key == "TARGET") { - childParams << string(name: param.key, value: "testList TESTLIST=" + failedTests ) + childParams << string(name: param.key, value: "testList TESTLIST=" + env.FAILED_TESTS) } else if (param.key == "PARALLEL") { childParams << string(name: param.key, value: "None") } else if (param.key == "NUM_MACHINES") { @@ -1281,8 +1280,7 @@ def run_parallel_tests() { archiveAQAvitFiles() if (buildPaths.length() > 0) { - String failedTests = addFailedTestsGrinderLink(buildPaths.substring(0, buildPaths.length() - 1)) - triggerRerunJob(failedTests) + addFailedTestsGrinderLink(buildPaths.substring(0, buildPaths.length() - 1)) } } finally { forceCleanWS() diff --git a/buildenv/jenkins/openjdk_tests b/buildenv/jenkins/openjdk_tests index f199425eda..7496ecd97b 100644 --- a/buildenv/jenkins/openjdk_tests +++ b/buildenv/jenkins/openjdk_tests @@ -340,6 +340,7 @@ timestamps{ } if (currentBuild.result != 'FAILURE') { jenkinsfile.run_parallel_tests() + jenkinsfile.triggerRerunJob() } } else { assert false : "Cannot find key PLATFORM: ${params.PLATFORM} in PLATFORM_MAP: ${PLATFORM_MAP}."