我正在尝试将一些特定日志文件的内容附加到邮件正文中,同时通过电子邮件确认作业执行失败。
stage("Checkout Fusion Source") {
parallel 'A': {
node('LinuxNode') {
try {
echo "Hello World(Linux)"
} catch (Exception e) {
mail body: 'Failed!',
subject: 'Job has failed in Linux!',
to: 'abc@xyz.com',
attachmentsPattern: '/path/to/log/file/log_linux.out'
}
mail body: 'Passed!',
subject: 'Job has passed in Linux!',
to: 'abc@xyz.com',
attachmentsPattern: '/path/to/log/file/log_linux.out'
}
}, 'B': {
node('AixNode') {
try {
echo "Hello World(AIX)"
} catch (Exception e) {
mail body: 'Failed!',
subject: 'Job has failed in AIX!',
to: 'abc@xyz.com',
attachmentsPattern: '/path/to/log/file/log_aix.out'
}
mail body: 'Passed!',
subject: 'Job has passed in AIX!',
to: 'abc@xyz.com',
attachmentsPattern: '/path/to/log/file/log_aix.out'
}
}
}
这attachmentsPattern
对此没有帮助。
附:我的詹金斯版本是2.46.3
。
答案 0 :(得分:2)
安装email-extension插件
在您的管道工作流程中尝试这样的事情。
emailext attachLog:true,body:“$ {currentBuild.result}:$ {BUILD_URL}”,compressLog:true,replyTo:'email@xxx.com', 主题:“构建通知:$ {JOB_NAME} - 建立#$ {BUILD_NUMBER} $ {currentBuild.result}”,发送至:'email123@xxx.com'