您所要求的(即在多个作业之间保持内部版本号相同)很简单不可能的在詹金斯。这是通过设计完成的(正如 Jenkins 创建者本人所指出的):"[JENKINS] assumes that the build number is unique and monotonic." http://jenkins-ci.361315.n4.nabble.com/Set-custom-build-number-td379762.html。您可以将其更改为更高的值,但将其更改为相同的数字将彻底破坏 Jenkins,因此是不可能的。
Build run数字就是:arun number.
应该是有顺序的。
It is not任何方式的版本号。
然而,有多种方法可以将版本控制信息添加到构建历史记录中。
描述 Setter 插件 https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin
这就是我用的。它不会改变内部版本号,而是描述,这是自动完成的。此外,由于这是描述,因此也可以随时手动修改。
This is what it looks like:
Note that builds #50
and #51
actually have the same version 1.3.0.394376
.
In that version string, the 1.3.0
is the current release number, as determined by the project properties, while the 394376
is actually an SVN revision number, obtained from $SVN_REVISION_1
build variable. So every time there is a new commit in SVN, I get a new revision number. But if there are no commits and the job is rebuilt for whatever reason (like in #50
and #51
), my version number remains same, as there was no code change.
我配置的方式是:
- 下载描述 Setter 插件 https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin
- 在你的某个地方构建步骤,输出您的版本*
- 我只是有:
echo Version is: ${internalVersionNumberFromWherever}.${SVN_REVISION_1}
- 下一步设置构建后操作 with 设置构建描述
- Setup 正则表达式从控制台提取版本号:
Version is: (.*)
- 将其他所有内容留空,以及 RegEx 中提取的内容
(.*)
将用作描述。
- 或者,您可以进一步设置描述文本为
Build - \1
. Where \1
是对第一组的引用(.*)
来自正则表达式。
- 任何时候你都可以manually通过从构建历史记录中选择构建运行并单击来更改运行的描述“编辑描述”右侧的链接(前提是用户已"Update"已配置权限)。
* 请注意,如果您的构建在输出版本文本的步骤之前失败,则描述设置器插件将无法获取它。如果您总是想查看版本,那么第一步就是设置版本号的显示。
Build Name Setter plugin https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin
This plugin will actually change the build number
However remember the limitation that each build number has to be unique.
Best way to ensure that is to add ${BUILD_NUMBER}
to whatever arbitrary number that you want (like in the image above). This way you can have builds numbers like 50.123
and then 50.124
where 50
is your version while 123
and 124
are sequential build run numbers, and Jenkins makes sure of keeping the ${BUILD_NUMBER}
unique.
最后,还有版本号插件 https://wiki.jenkins-ci.org/display/JENKINS/Version+Number+Plugin我没有亲自尝试过,但它可能对你有帮助。