有一个 Jenkins 管道。构建成功时需要/想要发送电子邮件。将有关所有分支的电子邮件发送到maillist-1并将 master 分支的构建过滤到maillist-master。
我尝试使用if
和when
语句步骤,但它们都在 post 块中失败。
pipeline {
agent ...
stages {...}
post{
success{
archiveArtifacts: ...
if( env.BRANCH_NAME == 'master' ){
emailext( to: 'maillist-master@domain.com'
, replyTo: 'maillist-master@domain.com'
, subject: 'Jenkins. Build succeeded :^) '
, body: params.EmailBody
, attachmentsPattern: '**/App*.tar.gz'
)
}
emailext( to: 'maillist-1@domain.com'
, replyTo: 'maillist-1@domain.com'
, subject: 'Jenkins. Build succeeded :^) '
, body: params.EmailBody
, attachmentsPattern: '**/App*.tar.gz'
)
}
}
}
如何实现想要的行为?