Parameterize the approver detail in Promoted Build Plugin in Jenkins

和自甴很熟 提交于 2019-12-08 09:36:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!