From fac88ba8ee998c7ec1352f1cc7bd9b55338ce25d Mon Sep 17 00:00:00 2001 From: Valeria Garcia Date: Tue, 17 Dec 2024 22:52:22 +0000 Subject: [PATCH 1/2] Feature ETP-893: Update HTML Report Publishing in Pipelines --- pipelines/unittests/Jenkinsfile | 123 ++++++++++++------- pipelines/unittests/JenkinsfileOracle | 166 ++++++++++++++------------ 2 files changed, 168 insertions(+), 121 deletions(-) diff --git a/pipelines/unittests/Jenkinsfile b/pipelines/unittests/Jenkinsfile index 223777d0..473066e1 100644 --- a/pipelines/unittests/Jenkinsfile +++ b/pipelines/unittests/Jenkinsfile @@ -239,7 +239,7 @@ spec: } } // __________________________________________________________________________________________ -// ------------------------------ WEB SERVICE TEST ------------------------------------------ +// ------------------------------ WEB SERVICES TESTS ---------------------------------------- stage ('Web Service Test Suite') { // MARK: Web Service Test Suite when { expression { @@ -261,21 +261,26 @@ spec: echo "--------------- WebserviceTestSuite Failed ---------------" echo 'Exception occurred: ' + e.toString() currentBuild.result = UNSTABLE - unstable('WebserviceTestSuite Failed') + unstable('WebservicesTestSuite Failed') env.STATUSTEST = "0" } finally { - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'WEBSERVICES TESTS REPORT', - reportTitles: '' - ]) + if (fileExists("build/reports/tests/test/")) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'WEBSERVICES TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of Webservices tests does not exist. Skipping HTML report publishing." + } + sh "${WORKSPACE}/${TOMCAT_FOLDER}/bin/catalina.sh stop" + sh "./gradlew --stop" } - sh "${WORKSPACE}/${TOMCAT_FOLDER}/bin/catalina.sh stop" - sh "./gradlew --stop" } } } @@ -290,7 +295,6 @@ spec: } } steps { - sh "./pipelines/unittests/build-update.sh ${REPO_NAME} ${COMMIT_INPROGRESS_STATUS} \"Running Test Suites\" ${ACCESS_TOKEN} ${GIT_COMMIT} ${BUILD_URL} \"${CONTEXT_BUILD}\"" container('compiler') { script { dir(REPO_NAME) { @@ -307,15 +311,21 @@ spec: unstable('CoreTestSuite Failed') env.STATUSTEST = "0" } finally { - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'com.smf.* TESTS REPORT', - reportTitles: '' - ]) + if (fileExists("build/reports/tests/test/")) { + publishHTML([ + allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'com.smf.* TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of com.smf.* tests does not exist. Skipping HTML report publishing." + } + } } } @@ -323,7 +333,7 @@ spec: } } // __________________________________________________________________________________________ -// ------------------------------- STANDALONE TEST ------------------------------------------ +// ------------------------------- STANDALONE TESTS ----------------------------------------- stage ('Standalone Test Suite') { // MARK: Standalone Test Suite when { expression { @@ -347,15 +357,20 @@ spec: unstable('StandaloneTestSuite Failed') env.STATUSTEST = "0" } finally { - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'STANDALONE TESTS REPORT', - reportTitles: '' - ]) + if (fileExists("build/reports/tests/test/")) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'STANDALONE TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing." + } } } } @@ -363,8 +378,8 @@ spec: } } // __________________________________________________________________________________________ -// ----------------------------------- SPOCK TEST ------------------------------------------- - stage ('Spock Test') { // MARK: Spock Test +// ----------------------------------- com.etendoerp.* TESTS -------------------------------- + stage ('Spock Test') { // MARK: com.etendoerp.* Test when { expression { env.STATUSBUILD == "1" @@ -388,15 +403,35 @@ spec: unstable('Spock Test failed!') env.STATUSTEST = "0" } finally { - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/spock-reports/', - reportFiles: '*.html', - reportName: 'SPOCK TESTS REPORT', - reportTitles: '' - ]) + if (fileExists('build/spock-reports/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/spock-reports/', + reportFiles: '*.html', + reportName: 'com.etendoerp.* SPOCK TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/spock-reports" + } else { + echo "Spock report directory of com.etendoerp.* tests does not exist. Skipping HTML report publishing." + } + + if (fileExists('build/reports/tests/test/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'com.etendoerp.* TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of com.etendoerp.* does not exist. Skipping HTML report publishing." + } } } } diff --git a/pipelines/unittests/JenkinsfileOracle b/pipelines/unittests/JenkinsfileOracle index 889ffa11..6182b921 100644 --- a/pipelines/unittests/JenkinsfileOracle +++ b/pipelines/unittests/JenkinsfileOracle @@ -188,7 +188,7 @@ spec: sh "$WORKSPACE/$TOMCAT_FOLDER/bin/catalina.sh start" sh "sleep 1m" echo 'Build of Etendo Core Finished' - env.STATUSTEST = "1" //flag to indicate if any test failed + env.STATUSTEST = "1" // flag to indicate if any test failed env.STATUSBUILD = "1" } catch (Exception e) { echo 'Build of Etendo Core FAILED' @@ -202,7 +202,7 @@ spec: } } //___________________________________________________________________________________________ -// ------------------------------ WEB SERVICE TEST ------------------------------------------ +// ------------------------------ WEB SERVICES TESTS ---------------------------------------- stage ('Web Service Test Suite'){ when { expression { @@ -216,35 +216,32 @@ spec: try { sh './pipelines/unittests/build-update.sh $REPO_NAME $COMMIT_INPROGRESS_STATUS "Running Test Suites" $ACCESS_TOKEN $GIT_COMMIT $BUILD_URL \"${CONTEXT_BUILD}\"' sh './gradlew test --tests org.openbravo.test.WebserviceTestSuite --info ' - publishHTML([ - allowMissing: true, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'WEB SERVICES TESTS REPORT', - reportTitles: '' - ]) } catch (Exception e) { - echo '....TEST WEBSERVICE FAILED....' + echo '....WEB SERVICES TESTS FAILED....' echo 'Exception occurred: ' + e.toString() currentBuild.result = UNSTABLE - unstable('Web Service Test Failed') + unstable('Web Service Tests Failed') env.STATUSTEST = "0" - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'WEBSERVICES TESTS REPORT', - reportTitles: '' - ]) + } finally { + if (fileExists('build/reports/tests/test/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'WEBSERVICES TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of Webservices tests does not exist. Skipping HTML report publishing." + } + sh "$WORKSPACE/$TOMCAT_FOLDER/bin/catalina.sh stop" + sh './gradlew --stop' } } } - sh "$WORKSPACE/$TOMCAT_FOLDER/bin/catalina.sh stop" - sh './gradlew --stop' } } } @@ -271,15 +268,20 @@ spec: unstable('CoreTestSuite Failed') env.STATUSTEST = "0" } finally { - publishHTML([ - allowMissing: true, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'com.smf.* TESTS REPORT', - reportTitles: '' - ]) + if (fileExists("build/reports/tests/test/")) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'com.smf.* TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of com.smf.* tests does not exist. Skipping HTML report publishing." + } } } } @@ -287,8 +289,8 @@ spec: } } //___________________________________________________________________________________________ -// ------------------------------- STANDALONE TEST ------------------------------------------ - stage ('Standalone Test Suite'){ +// ------------------------------- STANDALONE TESTS ----------------------------------------- + stage ('Standalone Test Suite') { when { expression { env.STATUSBUILD == "1" @@ -299,31 +301,28 @@ spec: script { dir(REPO_NAME) { try { - sh './gradlew test --tests org.openbravo.test.StandaloneTestSuite --info ' - publishHTML([ - allowMissing: true, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'STANDALONE TESTS REPORT', - reportTitles: '' - ]) + sh './gradlew test --tests org.openbravo.test.StandaloneTestSuite --info' } catch (Exception e) { - echo '....TEST STANDALONE FAILED....' + echo '....STANDALONE TESTS FAILED....' echo 'Exception occurred: ' + e.toString() currentBuild.result = UNSTABLE - unstable('Standalone Test Failed!') + unstable('Standalone Tests Failed!') env.STATUSTEST = "0" - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/reports/tests/test', - reportFiles: '*.html', - reportName: 'STANDALONE TESTS REPORT', - reportTitles: '' - ]) + } finally { + if (fileExists('build/reports/tests/test/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'STANDALONE TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing." + } } } } @@ -331,7 +330,7 @@ spec: } } //___________________________________________________________________________________________ -// ----------------------------------- SPOCK TEST ------------------------------------------- +// ----------------------------------- com.etendoerp.* TESTS ------------------------------------------- stage ('Spock Test') { when { expression { @@ -344,30 +343,43 @@ spec: dir(REPO_NAME) { try { sh './gradlew test --tests "com.etendoerp.*" --info' - publishHTML([ - allowMissing: true, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/spock-reports/', - reportFiles: '*.html', - reportName: 'SPOCK TESTS REPORT', - reportTitles: '' - ]) } catch (Exception e) { - echo '....TEST SPOCK FAILED....' + echo '....com.etendoerp.* TESTS FAILED....' echo 'Exception occurred: ' + e.toString() currentBuild.result = UNSTABLE - unstable('Spock Test failed!') + unstable('com.etendoerp.* Tests failed!') env.STATUSTEST = "0" - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'build/spock-reports/', - reportFiles: '*.html', - reportName: 'SPOCK TESTS REPORT', - reportTitles: '' - ]) + } finally { + if (fileExists('build/spock-reports/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/spock-reports/', + reportFiles: '*.html', + reportName: 'com.etendoerp.* SPOCK TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/spock-reports" + } else { + echo "Spock report directory of com.etendoerp.* tests does not exist. Skipping HTML report publishing." + } + + if (fileExists('build/reports/tests/test/')) { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/reports/tests/test', + reportFiles: '*.html', + reportName: 'com.etendoerp.* TESTS REPORT', + reportTitles: '' + ]) + sh "rm -rf build/reports/tests/test" + } else { + echo "Report directory of com.etendoerp.* does not exist. Skipping HTML report publishing." + } + } } } From c0402f3faa30f2854b9308e030be0c576b316d1d Mon Sep 17 00:00:00 2001 From: Valeria Garcia Date: Wed, 18 Dec 2024 15:38:54 +0000 Subject: [PATCH 2/2] Feature ETP-893: Replace spock to com.etendoerp.* in stage name --- pipelines/unittests/Jenkinsfile | 12 ++++++------ pipelines/unittests/JenkinsfileOracle | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pipelines/unittests/Jenkinsfile b/pipelines/unittests/Jenkinsfile index 473066e1..71956218 100644 --- a/pipelines/unittests/Jenkinsfile +++ b/pipelines/unittests/Jenkinsfile @@ -379,7 +379,7 @@ spec: } // __________________________________________________________________________________________ // ----------------------------------- com.etendoerp.* TESTS -------------------------------- - stage ('Spock Test') { // MARK: com.etendoerp.* Test + stage ('com.etendoerp.* Tests') { // MARK: com.etendoerp.* Test when { expression { env.STATUSBUILD == "1" @@ -390,17 +390,17 @@ spec: script { dir(REPO_NAME) { try { - echo "--------------- Running Spock Test ---------------" + echo "--------------- Running com.etendoerp.* Tests ---------------" sh "./gradlew test --tests \"com.etendoerp.*\" --info" sh "mv build/jacoco/test.exec build/jacoco/test3.exec" sh "./gradlew --stop" - echo "--------------- Spock Test Successful ---------------" + echo "--------------- com.etendoerp.* Tests Successful ---------------" currentBuild.result = SUCCESS } catch (Exception e) { - echo "--------------- Spock Test Failed ---------------" + echo "--------------- com.etendoerp.* Tests Failed ---------------" echo 'Exception occurred: ' + e.toString() currentBuild.result = UNSTABLE - unstable('Spock Test failed!') + unstable('com.etendoerp.* Tests failed!') env.STATUSTEST = "0" } finally { if (fileExists('build/spock-reports/')) { @@ -430,7 +430,7 @@ spec: ]) sh "rm -rf build/reports/tests/test" } else { - echo "Report directory of com.etendoerp.* does not exist. Skipping HTML report publishing." + echo "Report directory of com.etendoerp.* tests does not exist. Skipping HTML report publishing." } } } diff --git a/pipelines/unittests/JenkinsfileOracle b/pipelines/unittests/JenkinsfileOracle index 6182b921..86f01a73 100644 --- a/pipelines/unittests/JenkinsfileOracle +++ b/pipelines/unittests/JenkinsfileOracle @@ -331,7 +331,7 @@ spec: } //___________________________________________________________________________________________ // ----------------------------------- com.etendoerp.* TESTS ------------------------------------------- - stage ('Spock Test') { + stage ('com.etendoerp.* Tests') { when { expression { env.STATUSBUILD == "1"