jenkins通过电子邮件输入管道 [英] jenkins pipeline input via email

查看:57
本文介绍了jenkins通过电子邮件输入管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins管道我希望用户通过电子邮件进行输入我尝试了这个,但没有帮助.

I am using Jenkins pipeline I want user to give input via email I tried this but didnt helped.

def tok = UUID.randomUUID().toString()
mail to: 'admins@mycorp', subject: 'Ready to roll?', mimeType: 'text/html',
body: """Please <a href="${env.JENKINS_URL}pipeline-inputs/${tok}/proceed">approve me</a>!"""
input message: 'Ready?', token: tok

关于此的任何指针,我也想要令牌或任何类型的身份验证.预先感谢

Any pointer about this, I want token or any type of authentication also. Thanks in advance

推荐答案

        emailext mimeType: 'text/html',
                 subject: "[Jenkins]${currentBuild.fullDisplayName}",
                 to: "tom@xxx.com",
                 body: '''<a href="${BUILD_URL}input">click to approve</a>'''

        def userInput = input id: 'userInput',
                              message: 'Let\'s promote?', 
                              submitterParameter: 'submitter',
                              submitter: 'tom',
                              parameters: [
                                [$class: 'TextParameterDefinition', defaultValue: 'sit', description: 'Environment', name: 'env'],
                                [$class: 'TextParameterDefinition', defaultValue: 'k8s', description: 'Target', name: 'target']]

        echo ("Env: "+userInput['env'])
        echo ("Target: "+userInput['target'])
        echo ("submitted by: "+userInput['submitter'])

Tom将收到一封包含输入URL的邮件,只有Tom可以成功提交输入.

Tom will receive a mail containing the input url, and only tom can submit the input successfully.

这篇关于jenkins通过电子邮件输入管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆