From c8e58648389c7b0b476c3d0d47be86af2966842f Mon Sep 17 00:00:00 2001 From: Gautham B A Date: Tue, 24 Aug 2021 22:56:26 +0530 Subject: [PATCH] HADOOP-17854. Run junit in Jenkins only if surefire reports exist (#3319) --- dev-support/Jenkinsfile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dev-support/Jenkinsfile b/dev-support/Jenkinsfile index 2f48a9a8801..80e0572ac98 100644 --- a/dev-support/Jenkinsfile +++ b/dev-support/Jenkinsfile @@ -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() } }