-2

I have a jenkins pipeline where I wait for user input to proceed or abort. Is there any way I can send the same in email to let the concerned person aware and he can click on the email to procceed Or abort the pipeline.?

user2636464
  • 685
  • 7
  • 17

1 Answers1

1

It is possible to execute such action by using Jenkins API, this can be achieved using Jenkins Rest Api you can check this SO question.

I haven't tried this solution yet but I guess this pipeline could help you get a better idea of how I would think about implementing such behavior in a pipeline like this:

pipeline {
    agent any
    stages {
        stage('Mail Notification') {
          steps {
            echo 'Sending Mail'
            mail bcc: '',
            body: 'Stop job through this link: ${env.BUILD_URL}/job/${env.JOB_NAME}/${env.BUILD_NUMBER}/stop',
            cc: '',
            from: '',
            replyTo: '',
            subject: 'Jenkins Job',
            to: 'example@domain.com'
          }
        }
    }
}

Jenkins pipeline is aware of such variables like ${env.BUILD_URL} ${env.JOB_NAME} ${env.BUILD_NUMBER}

Affes Salem
  • 1,303
  • 10
  • 26