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

ercv8c1e  于 2023-03-01  发布在  Jenkins
关注(0)|答案(1)|浏览(147)

我试图为我们的UAT团队建立一个逻辑,只有在经理批准后才能部署代码。我想知道如何才能实现?电子邮件批准?。请帮助

vi4fp9gy

vi4fp9gy1#

你可以试试这样的

//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: "user@xxx.com",
                 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问题中获得更多帮助

相关问题