我正在尝试在 CloudHub 中部署 MuleSoft API 之前添加 Jenkins 审批阶段。我安装了电子邮件扩展插件并在我的管道中使用了以下脚本。我能够在 Jenkins 仪表板中获得批准弹出窗口,但无法在我的批准邮件 ID 上发送批准电子邮件链接。另外,在控制台日志中,我可以看到邮件正在发送到所需审批者的邮件 ID。目前我使用的是 Jenkins 版本 2.440.1。
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
// Add your build steps here
}
}
stage('Approval') {
steps {
script {
// Send email notification
emailext(
subject: "Approval Needed for Job ${env.JOB_NAME}",
body: "Please approve the build by clicking on the following link: ${env.BUILD_URL}input/",
to: "[email protected]"
)
// Wait for approval
input message: 'Do you approve this build?', submitter: '[email protected]'
}
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
// Add your deployment steps here
}
}
}
}
奇怪的是,我还使用部署后电子邮件阶段来通知构建状态,并且工作正常,我们也根据构建状态获取电子邮件。在 Jenkinsfile 中使用以下脚本。
post {
failure {
mail to: '[email protected]',
cc: '[email protected]',
subject: "Failed: Build ${env.JOB_NAME}",
body: "Build failed ${env.JOB_NAME} and Build number: ${env.BUILD_NUMBER} .\n\n View the logs at : \n ${env.BUILD_URL}"
}
success {
mail to: '[email protected]',
cc: '[email protected]',
subject: "Successful : Build ${env.JOB_NAME}",
body: "Build Successful ${env.JOB_NAME} and Build number: ${env.BUILD_NUMBER} .\n\n View the logs at : \n ${env.BUILD_URL}"
}
}
非常感谢任何人的意见。
我正在尝试在 CloudHub 中部署 MuleSoft API 之前添加 Jenkins 审批阶段。我安装了电子邮件扩展插件并在我的管道中使用了以下脚本。我能够在 Jenkins 仪表板中获得批准弹出窗口,但无法在我的批准邮件 ID 上发送批准电子邮件链接。目前我使用的是 Jenkins 版本 2.440.1
如果您可以使用
mail
步骤发送电子邮件,为什么还要使用电子邮件扩展插件及其 emailext
步骤呢?继续使用mail
:
// Send email notification
mail(
subject: "Approval Needed for Job ${env.JOB_NAME}",
body: "Please approve the build by clicking on the following link: ${env.BUILD_URL}input/",
to: "[email protected]"
)