HADOOP-17854. Run junit in Jenkins only if surefire reports exist (#3319)

This commit is contained in:
Gautham B A 2021-08-24 22:56:26 +05:30 committed by GitHub
parent fc566ad9b0
commit c8e5864838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,22 @@ def getGithubAndJiraCreds() {
usernameVariable: 'JIRA_USER')]
}
// Publish JUnit results only if there are XML files under surefire-reports
def publishJUnitResults() {
def findCmdExitCode = sh script: "find ${SOURCEDIR} -wholename */target/surefire-reports/*.xml | egrep .", returnStatus: true
boolean surefireReportsExist = findCmdExitCode == 0
if (surefireReportsExist) {
echo "XML files found under surefire-reports, running junit"
try {
junit "${SOURCEDIR}/**/target/surefire-reports/*.xml"
} catch(e) {
echo 'junit processing: ' + e.toString()
}
} else {
echo "No XML files found under surefire-reports, skipping junit"
}
}
pipeline {
agent {
@ -290,12 +306,7 @@ pipeline {
reportName: 'Yetus Report'
])
// Publish JUnit results
try {
junit "${SOURCEDIR}/**/target/surefire-reports/*.xml"
} catch(e) {
echo 'junit processing: ' + e.toString()
}
publishJUnitResults()
}
}