在流水线中发送电子邮件:
node('worker_node1') {
try {
...
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
}
finally {
mail to : 'test@qq.com',
subject: "Status of pipeline : ${currentBuild.fullDisplayName}",
body: "${env.BUILD_URL} has result ${currentBuild.result}"
}
}
声明式流水线:
pipeline {
agent any
stages {
...
}
post {
always {
mail to : 'test@qq.com',
subject: "Status of pipeline : ${currentBuild.fullDisplayName}",
body: "${env.BUILD_URL} has result ${currentBuild.result}"
}
}
}