简体   繁体   English

Jenkins版本升级:如何获取要升级的版本的版本ID?

[英]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. 看起来,当使用Promoted Builds插件在Jenkins中进行构建升级时,它将生成一个新的BUILD_ID环境变量。 Is there a way, or a plugin that lets you access the current BUILD_ID of the build you are trying to promote? 有没有办法或插件可以让您访问您要升级的构建的当前BUILD_ID?

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. 基本上,我需要的功能是:导航到Jenkins中的构建,能够启动ant或gradle脚本来提升已构建的工件,该工件存储在我当前使用的构建下。

Use the PROMOTED_JOB_NAME and PROMOTED_NUMBER variables to get the name and build number of the build being promoted. 使用PROMOTED_JOB_NAME和PROMOTED_NUMBER变量来获取要升级的内部版本的名称和内部版本号。 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. 这并不完全映射到BUILD_ID,但确实允许访问该版本。

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). 让原始作业将某些变量(如JOB_ID)复制到配置样式文件中(每行是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. 促销时,使用PROMOTED_JOB_NAME和PROMOTED_NUMBER变量获取原始版本,将值馈送到“ 复制工件”插件中以检索值的存档文件,然后使用带有该值文件的EnvInject插件将值带入推广过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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