-
-
Save bogdanRada/0414879442ab10ee8a6ec5303aff9f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage 'Test' | |
// Split the previously executed tests into 10 jobs | |
def splits = splitTests parallelism: [$class: 'CountDrivenParallelism', size: 10], generateInclusions: true | |
def branches = [:] | |
// Prepare each job | |
for (int i = 0; i < splits.size(); i++) { | |
def split = splits[i] | |
branches["split${i}"] = { | |
// The job should allocate a new jenkins slave | |
node('dockerSlave') { | |
// Checkout the code | |
checkout scm | |
// Write exclusion and inclusion files | |
writeFile file: (split.includes ? 'inclusions.txt' : 'exclusions.txt'), text: split.list.join("\n") | |
writeFile file: (split.includes ? 'exclusions.txt' : 'inclusions.txt'), text: '' | |
def mvnHome = tool 'M3' | |
// Execute the tests | |
sh "${mvnHome}/bin/mvn -B clean test -Dmaven.test.failure.ignore" | |
// Aggregate the junit test results | |
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml']) | |
} | |
} | |
} | |
// Execute all jobs in parallel | |
parallel branches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment