我有一个Jenkins声明式管道,它执行并行阶段。每个阶段的退出代码被分配给Groovy mapresults,并打印到日志控制台:
def p = [:] // map for parallel stages
def results = [:] // map of exit code for each stage
pipeline {
stages {
stage('run') {
steps {
script {
for (file in files_list) {
p[file] = {
node(myagent) {
results[file] = sh returnStatus: true, script:'./myApp $file'
}
}
}
parallel p
// Print the results
for (def key in results.keySet()) {
println "file = ${key}, exit code = ${results[key]}"
}
}
}
}
}
post {
success {
script { emailext (subject: "${env.JOB_NAME}: Build #${env.BUILD_NUMBER} - Successful!",
body: '${DEFAULT_CONTENT}',
recipientProviders: [buildUser()])
}
}
}
}
字符串
如何在成功后阶段发送的通知电子邮件的正文中包含Map的名称?
1条答案
按热度按时间nvbavucw1#
在并行执行之后,您可以将结果转换为全局保存的字符串,最后在发送邮件时将结果字符串与消息内容连接在一起。
比如说:
字符串