Browse Source

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

Gautham B A 3 years ago
parent
commit
c8e5864838
1 changed files with 17 additions and 6 deletions
  1. 17 6
      dev-support/Jenkinsfile

+ 17 - 6
dev-support/Jenkinsfile

@@ -24,6 +24,22 @@ def getGithubAndJiraCreds() {
                                 usernameVariable: 'JIRA_USER')]
                                 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 {
 pipeline {
 
 
     agent {
     agent {
@@ -290,12 +306,7 @@ pipeline {
                                       reportName: 'Yetus Report'
                                       reportName: 'Yetus Report'
                         ])
                         ])
 
 
-                        // Publish JUnit results
-                        try {
-                            junit "${SOURCEDIR}/**/target/surefire-reports/*.xml"
-                        } catch(e) {
-                            echo 'junit processing: ' + e.toString()
-                        }
+                        publishJUnitResults()
                     }
                     }
                 }
                 }