如何在 Jenkins 电子邮件通知中将 allure 或 html 报告作为附件发送
How to send allure or html report as an attachment in the Jenkins email notifications
如何在 Jenkins 电子邮件通知中将 allure 或 html 报告作为附件发送。这是我在 Jenkins 的管道脚本中使用的管道示例。我已经设置了我的电子邮件通知,但是我想在电子邮件中获得某种报告。请注意,仅提供 link 是不够的,因为我的测试是在与报告不同的机器上设置的。
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'echo "Fail!"; exit 1'
}
}
}
post {
always {
echo 'This will always run'
}
success {
echo 'This will run only if successful'
}
failure {
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "foo@foomail.com";
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
你应该使用 emailext
插件而不是 mail
failure {
emailext(
attachmentsPattern: "<path to report>",
body: '',
subject: "",
to: ""
)
}
如何在 Jenkins 电子邮件通知中将 allure 或 html 报告作为附件发送。这是我在 Jenkins 的管道脚本中使用的管道示例。我已经设置了我的电子邮件通知,但是我想在电子邮件中获得某种报告。请注意,仅提供 link 是不够的,因为我的测试是在与报告不同的机器上设置的。
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'echo "Fail!"; exit 1'
}
}
}
post {
always {
echo 'This will always run'
}
success {
echo 'This will run only if successful'
}
failure {
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "foo@foomail.com";
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
你应该使用 emailext
插件而不是 mail
failure {
emailext(
attachmentsPattern: "<path to report>",
body: '',
subject: "",
to: ""
)
}