手动取消Jenkins中的作业时,如何停止从Jenkins管道发送电子邮件
我有一个Jenkins管道,使用Groovy在构建失败或不稳定时通过电子邮件发送构建状态。但是当我在Jenkins中手动取消构建时,电子邮件仍然会发送,因为它认为这是失败的。如何使Jenkins在这种情况下不发送电子邮件?您可以使用手动取消Jenkins中的作业时,如何停止从Jenkins管道发送电子邮件,jenkins,groovy,jenkins-pipeline,pipeline,Jenkins,Groovy,Jenkins Pipeline,Pipeline,我有一个Jenkins管道,使用Groovy在构建失败或不稳定时通过电子邮件发送构建状态。但是当我在Jenkins中手动取消构建时,电子邮件仍然会发送,因为它认为这是失败的。如何使Jenkins在这种情况下不发送电子邮件?您可以使用FlowInterruptedException,例如,我的“不优雅但有效”解决方案: import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException node(){ stage("do
FlowInterruptedException
,例如,我的“不优雅但有效”解决方案:
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
node(){
stage("doing things"){
sendEmailflag = true
try{
echo "into try block"
sleep 10
}
catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
sendEmailflag = false
echo "!!!caused error $e"
throw e
}
finally{
if(sendEmailflag == false)
{echo "do not send e-mail"}
else
{echo "send e-mail"}
}
}
}
这是基于:
您可以使用
FlowInterruptedException
,例如,我的不优雅但有效的解决方案:
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
node(){
stage("doing things"){
sendEmailflag = true
try{
echo "into try block"
sleep 10
}
catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
sendEmailflag = false
echo "!!!caused error $e"
throw e
}
finally{
if(sendEmailflag == false)
{echo "do not send e-mail"}
else
{echo "send e-mail"}
}
}
}
这是基于:
不能只说FlowInterruptedException而不说它在哪里。不能只说FlowInterruptedException而不说它在哪里。