简体   繁体   中英

Jenkins build promotion: How do I get the build id of the build I want to promote?

It seems that, when doing a build promotion in Jenkins using the Promoted Builds Plugin, it generates a new BUILD_ID environment variable. Is there a way, or a plugin that lets you access the current BUILD_ID of the build you are trying to promote?

Basically, the functionality I need is to: Navigate to a build in Jenkins, be able to launch an ant or gradle script to promote an already built artifact that is archived under the build I'm currently in.

Use the PROMOTED_JOB_NAME and PROMOTED_NUMBER variables to get the name and build number of the build being promoted. These two values are only set DURING the promotion process; they are part of the jobs build. This doesn't exactly map to BUILD_ID, but it does allow access to that build.

When I had this problem in the past, I did the following.

  1. Have the original job copy certain variables (like JOB_ID) out to config style file (each line is NAME=VALUE).
  2. Archive that file as part of the build.
  3. At the time of the promotion, use the PROMOTED_JOB_NAME and PROMOTED_NUMBER variables to get the original build, feed the values into the Copy Artifact Plugin to retrieve the archived file of values, then use the EnvInject Plugin with that values file to bring the values into the promotion process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM