Hello Everyone, I am trying to add Jenkins approval stage before the deployment of MuleSoft API in CloudHub. I installed Email extension plugin and used below script in my pipeline. I am able to get approval pop-up in Jenkins dashboard but is unable to send approval email link on my approval’s mail id. Currently I am using Jenkins version 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: "approver@example.com"
)
// Wait for approval
input message: 'Do you approve this build?', submitter: 'approver@example.com'
}
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
// Add your deployment steps here
}
}
}
}
And Strange thing is that I used Post Deployment Email stage as well to notify the build status and that is working fine and we are getting the Email as well based on the build status. Used below script in Jenkinsfile.
post {
failure {
mail to: 'team@example.com',
cc: 'team2@examlpe.com',
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: 'team@example.com',
cc: 'team2@examlpe.com',
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}"
}
}
Anyone’s input is much appreciated.