我正在尝试为我们的 UAT 团队构建一个逻辑,仅在经理批准后才能部署代码。我想知道怎样才能实现?电子邮件批准?请帮忙
最佳答案
你可以尝试这样的事情
//this will grab user - who is running the job
def user
node {
wrap([$class: 'BuildUser']) {
user = env.BUILD_USER_ID
}
emailext mimeType: 'text/html',
subject: "[Jenkins]${currentBuild.fullDisplayName}",
to: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82f7f1e7f0c2fafafaace1edef" rel="noreferrer noopener nofollow">[email protected]</a>",
body: '''<a href="${BUILD_URL}input">click to approve</a>'''
}
pipeline {
agent any
stages {
stage('deploy') {
input {
message "Should we continue?"
ok "Yes"
}
when {
expression { user == 'hardCodeApproverJenkinsId'}
}
steps {
sh "echo 'describe your deployment' "
}
}
}
}
您还可以从此 StackOverflow 获得更多帮助问题
关于Jenkins 部署前手动批准电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66050811/