- 发送邮件
https://blog.csdn.net/qq_30141993/article/details/81031151
import jenkins.model.*
@NonCPS
def getJobNames() {
Hudson.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob)*.fullName
}
pipeline {
agent any
stages {
stage('Test Stage') {
steps {
sh '''
pwd
'''
}
}
stage('getJobNames') {
steps {
script {
def jobNames = getJobNames()
def matchjobs = jobNames.findAll{ name -> name =~ /(test)\w*/ }
// println matchjobs
matchjobs.each {
try {
println(it)
res = jenkins.model.Jenkins.instance.getItem(it).lastBuild.getResult()
println res
} catch (NullPointerException e1) {
e1.printStackTrace();
}
}
}
}
}
}//stages
post {
always {
echo 'This will always run'
script {
emailext (subject:'${ENV, var ="JOB_NAME"}',
body:'${FILE ,path="email.html"}',
to:'sgamize@sina.com',)
}
}
success {
echo 'This will run only if successful'
}
failure {
echo 'This will run only if failed'
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
原文地址:https://www.cnblogs.com/amize/p/14774013.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。