Alien
Alien

Reputation: 109

Is it possible to use promoted builds in Jenkins pipeline and trigger a pipeline job after approving through email

i wanted to send an email to developers to do manual testing and a link to approve the build and then to do the build in production.Can anyone achieve this using jenkins

Upvotes: 0

Views: 275

Answers (1)

nandilov
nandilov

Reputation: 719

You can have a step on your pipeline as per below. They cannot approve it on the email, but you can send the URL of the job build on the email:

stage("Stage with input") {
    steps {
      def userInput = false
        script {
            // build your custom email message here
            emailext (
             subject: "Job: ${env.JOB_NAME} - ${env.BUILD_NUMBER}",
             body: """Job ${env.JOB_NAME} [${env.BUILD_URL}]""",
             recipientProviders: "[email protected]"
            )

            def userInput = input(id: 'Proceed1', message: 'Promote build?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']])
            echo 'userInput: ' + userInput

            if(userInput == true) {
                // do action
            } else {
                // not do action
                echo "Action was aborted."
            }

        }    
    }  
}

Check here email ext plugin. And here the input step.

Upvotes: 0

Related Questions