#!/bin/bash
cd ${WORKSPACE}/${JOB_BASE_NAME}
sudo ${MAVENHOME}/bin/mvn org.jacoco:jacoco-maven-plugin:prepare-agent -f pom.xml -s ${MAVENHOME}/tmp/settings.xml -gs ${MAVENHOME}/tmp/settings.xml clean test -Dautoconfig.skip=true -Dmaven.test.skip=false -Dmaven.test.failure.ignore=true
/**
* 执行单元测试,并收集结果
* @return
*/
def junitTest() {
def junitTestSh = libraryResource encoding: 'yss', resource: junittest
sh(script: "${junitTestSh}${shellMsgToWrite}", label: '执行单元测试', returnStdout: needShellReturn)
dir("${JOB_BASE_NAME}") {
junit "**/target/surefire-reports/TEST-*.xml"
//jacoco指标参数https://jenkins.io/doc/pipeline/steps/jacoco/
jacoco changeBuildStatus: true,
maximumClassCoverage: "${classCoverage}",
maximumMethodCoverage: "${methodCoverage}",
maximumBranchCoverage: "${branchCoverage}",
maximumLineCoverage: "${lineCoverage}"
//archiveArtifacts artifacts: '**/target/surefire-reports/TEST-*.xml', fingerprint: true
}
}