I have created an Build Pipeline in Jenkins as below.
Configuration Detail of Build Pipeline as follows.
1:
I have successfully configure the Email on Jenkins at pic 5 and it is working fine. I can receive email when build pass or fail.
How can i configure Manual Approval on my build, so that email can be generated and Admin can use the Jenkin's console link in the email to login and Approve the Build.
How can i do this.
node
{def jobName = currentBuild.fullDisplayName
def mailToRecipients = 'adeel.imtiaz@gmail.com'
def useremail = 'adeel.imtiaz@gmail.com'
stage("Build")
{
echo "Build"
}
stage("Test")
{
def userAborted = false
emailext body: '''
Dear Admin, <br>
Please go to console output of ${BUILD_URL}input to approve or Reject.<br>
''',
mimeType: 'text/html',
subject: "[Jenkins] ${jobName} Build Approval Request",
from: "${useremail}",
to: "${mailToRecipients}",
recipientProviders: [[$class: 'CulpritsRecipientProvider']]
try {
userInput = input submitter: 'Administrator', message: 'Do you approve?'
}
catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e)
{
cause = e.causes.get(0)
echo "Abroted by" + cause.getUser().toString()
userAbroted = true
echo "System aborted, but looks like timeout period did'nt complete. Aborting."
}
if (userAborted) {
currentBuild.result = 'ABORTED'
}
else {
echo "Testing"
}
}
stage('Deploy')
{
echo "Deploy"
}}
Thanks to Sir, Anand Video