问题
I have a requirement of trigerring a Job B after Job A executes successfully. After Job A executes successfully , an email notification will be sent to the approver . The approver will receive an email and click on the mail link . He will be routed to Jenkins page where he will approve the execution of Job B .
I am not sure which plugin to use where I can mention the name of the approver , how the approver can click on the link and simple say "approve" after logging in to the Jenkins page.
回答1:
- Setup
Job A - Configure
Job Ato send email to your "approver" as part of Email Ext post-build action - Configure the email to contain link back to the job run (not just job name, or you could even link directly to promotion from the email)
- Configure a Promotion on
Job A - In that promotion, allow it to be run only by your "approver" user (by name)
- Configure that promotion to trigger
Job B
When Job A is run, it will send email to "approver". He/she will click the link and come to the Jenkins job run UI. He/she should be logged in to Jenkins with their "approver" user.
Then he/she can click the promotion star and simply click "approve" on it. This will trigger the promotion which in turn triggers Job B
Note: you can achieve something similar without "Promotions" plugin, but this is exactly the reason why that plugin exists, so use it.
回答2:
Another option is to use the Jenkins Workflow plugin (as per the jenkins-workflow tag on the question), which is designed for this kind of more complex system. You would write something like (off the top of my head):
build job: 'A', wait: true
mail to: 'user@…', subject: "Please approve #${env.BUILD_NUMBER}", body: """
See ${env.BUILD_URL}input/
"""
input submitter: 'userId', message: 'Ready?'
build job: 'B', wait: true
Later the build steps can be replaced with actual build tasks by inlining the work of those freestyle jobs.
来源:https://stackoverflow.com/questions/31076928/kick-off-a-job-after-manual-approval-in-jenkins