Jenkins BUILD_NUMBER限制 - 最大内部版本号

问题描述 投票:1回答:1

想知道Jenkins内部版本号(BUILD_NUMBER)可以获得的最大数量是多少?我试图在网上找到但是找不到这个信息。

它是无限的还是有一些限制(INT或INT64或其他类型)?

PS:我不是在寻找如何使用以下插件将其重置回#1或#N或将其设置为给定名称(使用Set build name plugin)。 https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin

为了找到它的限制,使用Next Build Number插件 - 当我将构建设置为“65,535”时,它仍然成功地让我获得65536并且我继续将此值增加到999999999(9次),并且它仍然有效,即下一个构建运行了100万,并为少数其他运行/构建获得了有效的Jenkins构建#。

当我尝试将下一个内部版本号设置为:9999999999(10次)时,Jenkins插件使用错误消息(显示我设置的下一个内部版本号不是INTEGER,即不在范围内):

A problem occurred while processing the request. Please check our bug tracker to see if a similar problem has already been reported. If it is already reported, please vote and put a comment on it to let us gauge the impact of the problem. If you think this is a new issue, please file a new issue. When you file an issue, make sure to add the entire stack trace, along with the version of Jenkins and relevant plugins. The users list might be also useful in understanding what has happened.

Stack trace

javax.servlet.ServletException: Build number must be an integer
    at org.jvnet.hudson.plugins.nextbuildnumber.NextBuildNumberAction.doSubmit(NextBuildNumberAction.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jenkins integer range jenkins-plugins build-numbers
1个回答
2
投票

找到Jenkins BUILD_NUMBER是一个SIGNED Integer数据类型,INT签名限制是:

int 2 or 4 bytes    -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647

因此,可以设置或构建Jenkins作业的最后一个值是:2147483647(此处为4个字节)。设置高于此数字的任何内容都将生成预期的INT限制错误。

使用SET NEXT BUILD NUMBER插件注意到以下问题:

  1. 如果我将下一个版本号设置在-2147483648或2147483647(正)之间,则此插件在两种情况下均可使用,即给出负数或正数并设置它不会出错。但是,如果你已经达到了构建#2147483647(在作业历史记录下),那么即使将构建#设置为1也不会生成下一个构建为1或2。或3等等。
  2. 由于BUILD_NUMBER是SIGNED(在上面的范围内是-N到+ N),并且ex:设置-22用于使用插件设置下一个构建#,它没有给我构建#-21或构建#21在我的案件。

发生了什么,虽然提供了一个负值/低于上一个/上一个构建#的值,然后这个插件将该值带入限制范围内,但实际上没有做任何事情/给我预期的BUILD#。当我点击Build Now /每次点击Build Now时,如果点击“Set Next Build Number”来检查值,我注意到框中列出的数字是自动递减的次数我点击“立即构建”(仅当您达到限制时才会发生这种情况),负值/较低值对下一个构建号码没有影响(根据插件文档)。

我通过创建一个新的test_job来测试这个(通过仅保留1个构建来丢弃旧的构建):

  1. 点击Build Now,获得Build#1。
  2. 将下一个内部版本号设置为100。
  3. 点击Build Now,获得Build#100,Clicked Build now,build#101。
  4. 这次将Build number设置为11。
  5. 点击Build Now,但不是给我构建#12,Jenkins给了我构建#102(PS:这是该插件的预期行为,根据它的文档,将下一个构建号设置为较低的数字N将不会做任何事情)。
© www.soinside.com 2019 - 2024. All rights reserved.