分享一个Jenkins发送邮件的不同方法

参数化工程

选择String parameter,这里会输入接收者,可以多选用分号隔开;
在这里插入图片描述

在Pipeline中定义参数![

](https://i-blog.csdnimg.cn/direct/b6cfe2e2a0ae4f089a3de20c09b3a6c7.png)

在这里插入图片描述

parameters {
        string(name: 'Receiver_Email', defaultValue: 'xx@yourEmail.com', description: 'Add some receiver email adress')       
    }

Post 中调用参数

在这里插入图片描述

post {
        success {
            script {
                echo "Build successful"
            }
        }
 
        failure {
            script {
                echo "Build failed"
            }
        }
                    
        always {
            // Send email if the ZIP file does not exist
            script {
                    echo "Sending email due to missing ${MODEL_NAME}_CodeFiles.zip"
                    emailext (
                        subject: "Compilation Error Notification",
                        body: "The MATLAB model compilation has failed. Please check the logs.",
                        to: " ${Receiver_Email}"                  
                    )
                }
            }
        }
    }
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值