问题
I am using Promote Build plugin in Jenkins . I need to take the approver information from the user in Jenkins and provide him the approval rights . Here is what I am trying to do :
Is it feasible ?
回答1:
Don't think you can use variables there. However, you could skip that condition, and instead have an Execute Shell build step, and there check for variables $PROMOTED_USER_NAME
. Parse the name, and make your decision based on that.
Parent parameters don't automatically get passed to Promoted builds. However, you can export them to file, archive the file (important to archive as opposed to keep it in workspace), bring the file over in the promotion step, and either load it to environment variables with EnvInject plugin, or simply use the file as is in a script
On Parent Job
- Configure parameter
approverid
- Have an Execute Shell build step with the following:
echo approverid=$approverid > myfile
- At the end, make sure to Archive
myfile
On Promotion Configuration
- Skip the approval criteria
- Add Copy Artifacts from another project step
- For Project Name, use
$PROMOTED_JOB_NAME
- For Which build, use Specific Build, then provide
$PROMOTED_NUMBER
- For Artifacts to copy, use
myfile
- Add Inject Environment Variables build step
- For Properties File Path, enter
myfile
- Add Execute Shell build step
- In that shell, compare values of
$approverid
and$PROMOTED_USER_NAME
- If they match, continue, else abort/exit promotion.
Or course, the history of execution (and abort) will be noted however.
来源:https://stackoverflow.com/questions/31082154/parameterize-the-approver-detail-in-promoted-build-plugin-in-jenkins