如何基于多个项目在电子邮件正文中发送html文件? 使用下面的简单代码能够发送邮件,但是如果我使用“ if else condition”,则它失败了,是否可以使用if条件为格式?
直接代码:
always {
emailext mimeType: 'text/html',
body: '${FILE,path="./logs/${JOB_NAME}_Build_${BUILD_NUMBER}/misc/email_dashboard.html"}',
subject: '${JOB_NAME} Report',
to: 'xyz.com'
}
我正在努力实现以下目标:
post {
success {
archiveArtifacts 'logs/${JOB_BASE_NAME}_Build_${BUILD_NUMBER}/**/*, logs/static_results/*'
script {
load "logs/${JOB_BASE_NAME}_Build_${BUILD_NUMBER}/display/pipeline_vars.groovy"
}
}
if ((${NODE_NAME}.contains("KG"))&&(${JOB_NAME}.contains("Nightly"))) {
always {
emailext mimeType: 'text/html',
body: '${FILE,path="./logs/${JOB_NAME}_Build_${BUILD_NUMBER}/misc/email_dashboard.html"}',
subject: '${JOB_NAME} Report',
to: 'xyz.com'
}
}
else if ((${NODE_NAME}.contains("MT")) &&(${JOB_NAME}.contains("Feature"))) {
always {
emailext mimeType: 'text/html',
body: '${FILE,path="./logs/${JOB_NAME}_Build_${BUILD_NUMBER}/misc/email_dashboard.html"}',
subject: '${JOB_NAME} Report',
to: 'xyz.com'
}
}
}
答案 0 :(得分:2)
答案 1 :(得分:0)
以下代码解决了我的问题:
always {
script {
if (env.JOB_NAME.contains('Nightly'))
{
emailext (
to: '${DEFAULT_RECIPIENTS}',
subject: "${env.JOB_NAME}-Report",
body: '${FILE,path="./logs/${JOB_NAME}_Build_${BUILD_NUMBER}/misc/xyz.html"}',
attachLog: true,
attachmentsPattern: 'logs/${JOB_NAME}_Build_${BUILD_NUMBER}/misc/xyz.png',
)
}
}
}