Jenkins 部署前手动批准电子邮件

标签 jenkins jenkins-pipeline

我正在尝试为我们的 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/

相关文章:

jenkins - 如何在声明式管道中等待用户输入而不阻塞重量级执行器

ios - build.xml 中唯一的 Xcode BUILD_PATH 环境变量不可用

jenkins - 如何使用 GitHub Org 插件从 jenkins 管道 (jenkinsfile) 触发另一个作业?

jenkins - 如何使用 Jenkins 管道写出环境变量

Jenkins 管道 sshPublisher : How to get exit code and output of execCommand?

Selenium 测试在 Jenkins 运行时失败,但在命令行运行时成功

Jenkins 动态触发另一个构建/项目

python - Jenkins 在构建 conda 包时不包含引用文件

jenkins - 如何在 Jenkins 管道中抛出异常?

java - 使用 JDK 8 启动 Jenkins,无需更改系统 java_home