This is an automated email from the ASF dual-hosted git repository.

benw pushed a commit to branch javax
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit b0b979334e2534efd35d77574cc32c107b2c79ec
Author: Ben Weidig <[email protected]>
AuthorDate: Sun Apr 5 16:48:38 2026 +0200

    TAP5-2819: Jenkinsfile notification mails improved
---
 Jenkinsfile                      | 69 ++++++++++++++++++++++++++++++----------
 Jenkinsfile.integration-variants | 69 ++++++++++++++++++++++++++++++----------
 2 files changed, 104 insertions(+), 34 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 60d199cce..3c72adf88 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -102,24 +102,59 @@ pipeline {
     }
 
     post {
-        failure {
-            emailext (
-                to: "${env.MAIL_NOTIFICATION}",
-                subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
-                body: """<p>FAILED: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]':</p>
-                         <p>Check console output at &quot;<a 
href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&quot;</p>""",
-                recipientProviders: [[$class: 'DevelopersRecipientProvider']]
-            )
-        }
+        fixed    { sendMail('FIXED') }
+        unstable { sendMail('UNSTABLE') }
+        failure  { sendMail('FAILURE') }
+        aborted  { sendMail('ABORTED') }
+    }
+}
+
+// MAIL NOTIFICATIONS
+
+def getChangeLog() {
+    def log = ""
+    def changeSets = currentBuild.changeSets
 
-        unstable {
-            emailext (
-                to: "${env.MAIL_NOTIFICATION}",
-                subject: "UNSTABLE: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]'",
-                body: """<p>UNSTABLE: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]':</p>
-                         <p>Check console output at &quot;<a 
href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&quot;</p>""",
-                recipientProviders: [[$class: 'DevelopersRecipientProvider']]
-            )
+    if (changeSets.isEmpty()) {
+        return "No changes recorded (Manual build or no new commits)."
+    }
+
+    for (int i = 0; i < changeSets.size(); i++) {
+        def entries = changeSets[i].items
+        for (int j = 0; j < entries.length; j++) {
+            def entry = entries[j]
+            log += "[${entry.author}] ${entry.msg}\n"
         }
     }
+    return log
+}
+
+def sendMail(buildStatus) {
+    emailext (
+        subject: "[${buildStatus}] ${env.JOB_NAME} - Build 
#${env.BUILD_NUMBER}",
+        body: """
+STATUS: ${buildStatus}
+Build URL: ${env.BUILD_URL}
+Duration: ${currentBuild.durationString.replace(' and counting', '')}
+
+-----------------------------------------------------------
+CHANGES
+-----------------------------------------------------------
+${getChangeLog()}
+
+-----------------------------------------------------------
+TEST RESULTS
+-----------------------------------------------------------
+\${TEST_COUNTS, var="total"} Tests: \${TEST_COUNTS, var="pass"} Passed, 
\${TEST_COUNTS, var="fail"} Failed, \${TEST_COUNTS, var="skipped"} Skipped
+
+-----------------------------------------------------------
+FAILED TESTS (if any)
+-----------------------------------------------------------
+\${FAILED_TESTS, maxTests=10, showStack=false}
+        """,
+        recipientProviders: [
+            developers(), // People who have commits in this build
+            requestor()   // The person who manually triggered the build
+        ]
+    )
 }
diff --git a/Jenkinsfile.integration-variants b/Jenkinsfile.integration-variants
index f05e20e98..192f358f5 100644
--- a/Jenkinsfile.integration-variants
+++ b/Jenkinsfile.integration-variants
@@ -99,24 +99,59 @@ pipeline {
     }
 
     post {
-        failure {
-            emailext (
-                to: "${env.MAIL_NOTIFICATION}",
-                subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
-                body: """<p>FAILED: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]':</p>
-                         <p>Check console output at &quot;<a 
href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&quot;</p>""",
-                recipientProviders: [[$class: 'DevelopersRecipientProvider']]
-            )
-        }
+        fixed    { sendMail('FIXED') }
+        unstable { sendMail('UNSTABLE') }
+        failure  { sendMail('FAILURE') }
+        aborted  { sendMail('ABORTED') }
+    }
+}
+
+// MAIL NOTIFICATIONS
+
+def getChangeLog() {
+    def log = ""
+    def changeSets = currentBuild.changeSets
+
+    if (changeSets.isEmpty()) {
+        return "No changes recorded (Manual build or no new commits)."
+    }
 
-        unstable {
-            emailext (
-                to: "${env.MAIL_NOTIFICATION}",
-                subject: "UNSTABLE: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]'",
-                body: """<p>UNSTABLE: Job '${env.JOB_NAME} 
[${env.BUILD_NUMBER}]':</p>
-                         <p>Check console output at &quot;<a 
href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&quot;</p>""",
-                recipientProviders: [[$class: 'DevelopersRecipientProvider']]
-            )
+    for (int i = 0; i < changeSets.size(); i++) {
+        def entries = changeSets[i].items
+        for (int j = 0; j < entries.length; j++) {
+            def entry = entries[j]
+            log += "[${entry.author}] ${entry.msg}\n"
         }
     }
+    return log
+}
+
+def sendMail(buildStatus) {
+    emailext (
+        subject: "[${buildStatus}] ${env.JOB_NAME} - Build 
#${env.BUILD_NUMBER}",
+        body: """
+STATUS: ${buildStatus}
+Build URL: ${env.BUILD_URL}
+Duration: ${currentBuild.durationString.replace(' and counting', '')}
+
+-----------------------------------------------------------
+CHANGES
+-----------------------------------------------------------
+${getChangeLog()}
+
+-----------------------------------------------------------
+TEST RESULTS
+-----------------------------------------------------------
+\${TEST_COUNTS, var="total"} Tests: \${TEST_COUNTS, var="pass"} Passed, 
\${TEST_COUNTS, var="fail"} Failed, \${TEST_COUNTS, var="skipped"} Skipped
+
+-----------------------------------------------------------
+FAILED TESTS (if any)
+-----------------------------------------------------------
+\${FAILED_TESTS, maxTests=10, showStack=false}
+        """,
+        recipientProviders: [
+            developers(), // People who have commits in this build
+            requestor()   // The person who manually triggered the build
+        ]
+    )
 }

Reply via email to