diff --git a/buildenv/jenkins/JenkinsfileBase b/buildenv/jenkins/JenkinsfileBase index a7dd233357..d9eda7bbc8 100644 --- a/buildenv/jenkins/JenkinsfileBase +++ b/buildenv/jenkins/JenkinsfileBase @@ -249,12 +249,15 @@ def setupParallelEnv() { NUM_LIST = genParallelList(PARALLEL_OPTIONS) } - if (NUM_LIST > 0) { + if (NUM_LIST > 1) { childJobNum = NUM_LIST echo "Saving parallelList.mk file on jenkins..." dir('aqa-tests/TKG') { archiveArtifacts artifacts: 'parallelList.mk', fingerprint: true, allowEmptyArchive: false } + } else if (NUM_LIST == 1) { + echo " Number of test list is 1, no need to run tests in child job." + return NUM_LIST } else { assert false : "Build failed because cannot find NUM_LIST in parallelList.mk file." } @@ -262,6 +265,7 @@ def setupParallelEnv() { UPSTREAM_TEST_JOB_NAME = JOB_NAME UPSTREAM_TEST_JOB_NUMBER = BUILD_NUMBER + echo "[PARALLEL: ${params.PARALLEL}] childJobNum is ${childJobNum}, creating jobs and running them in parallel..." parallel_tests = [:] create_jobs = [:] @@ -315,7 +319,7 @@ def setupParallelEnv() { if (create_jobs) { parallel create_jobs } - + return NUM_LIST // return to top level pipeline file in order to exit node block before running tests in parallel } @@ -969,7 +973,10 @@ def testBuild() { // prepare environment and compile test projects if ((params.PARALLEL == "NodesByIterations" && NUM_MACHINES > 1) || (params.PARALLEL == "Dynamic" && (NUM_MACHINES > 1 || (params.TEST_TIME && !params.NUM_MACHINES)))) { - setupParallelEnv() + if (setupParallelEnv() == 1) { + // No need to run tests in parallel + testExecution() + } } else { testExecution() }