diff --git a/Jenkinsfile b/Jenkinsfile index 1429fcb0c..25862b2fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,8 +26,20 @@ stage('Tests') { try { writeFile file: (split.includes ? "$WORKSPACE_TMP/includes.txt" : "$WORKSPACE_TMP/excludes.txt"), text: split.list.join("\n") writeFile file: (split.includes ? "$WORKSPACE_TMP/excludes.txt" : "$WORKSPACE_TMP/includes.txt"), text: '' - sh './kind.sh -Dsurefire.includesFile="$WORKSPACE_TMP/includes.txt" -Dsurefire.excludesFile="$WORKSPACE_TMP/excludes.txt"' + sh './kind.sh -Penable-jacoco -Dsurefire.includesFile="$WORKSPACE_TMP/includes.txt" -Dsurefire.excludesFile="$WORKSPACE_TMP/excludes.txt"' junit 'target/surefire-reports/*.xml' + withEnv(['NUM=' + num]) { + sh ''' + for f in $(find . -name jacoco.exec) + do + mv "$f" "$(echo "$f" | sed s/jacoco./jacoco-$NUM./)" + done + ''' + } + if (num == 0) { + stash name: 'classes', includes: '**/target/classes/**' + } + stash name: 'coverage-exec-' + num, allowEmpty: true, includes: '**/target/jacoco*.exec' } finally { dir(env.WORKSPACE_TMP) { if (fileExists('kindlogs/docker-info.txt')) { @@ -52,6 +64,17 @@ stage('Tests') { } } parallel branches + stage('aggregate coverage') { + node('maven-17') { + checkout scm + unstash 'classes' + for (int i = 0; i < splits.size(); i++) { + unstash 'coverage-exec-' + i + } + sh 'mvn -B -ntp -P merge-jacoco-reports validate' + recordCoverage(tools: [[parser: 'JACOCO', pattern: '**/jacoco/jacoco.xml']], sourceCodeRetention: 'MODIFIED') + } + } } // Stage part of the library infra.maybePublishIncrementals() diff --git a/pom.xml b/pom.xml index 17e4b1f3d..3a905fd00 100644 --- a/pom.xml +++ b/pom.xml @@ -342,4 +342,46 @@ + + + merge-jacoco-reports + + + + org.jacoco + jacoco-maven-plugin + + + + merge + + validate + + + + ${project.build.directory} + + jacoco-*.exec + + + + + + + build-report + + report + + validate + + XML + + + + + + + + +