在 Jenkins 中使用 versionNumber 插件
using versionNumber plugin in Jenkins
上下文:
我们构建我们的 Maven 应用程序,其中版本号由 build.properties
文件注入。这种方法的问题是对于每个版本,版本号都需要手动 bumped。
在线浏览以解决此问题,我遇到了 version number plugin,它提供了一些很酷的方法来解决此问题。
例如-Dproject.version=${BUILD_YEAR}.${BUILDS_THIS_YEAR}
会为我解决问题
问题
我在设置已定义变量的值时遇到问题
引用文档:
Initialization Values
Before the build is started, the number of
builds this year / month / week / day can be specified on the command
line or via the job's plugin-configuration web-GUI. If they are
specified, then they will override whatever values are currently in
production. This allows you to migrate your version number from
another system to Jenkins if you choose to do so.
Additionally, it is possible to automatically override the number of
builds this year / month / week / day with values taken from
environment-variables. Instead of just providing a simple number in
the form-fields of the job's plugin-configuration which overrides the
value for the next build (as described above), you can instead provide
an environment-variable whose value will be extracted and used during
the next builds. If it is not set or its value is not convertible to a
positive integer (without loosing precision), the value of the
previous build will be taken instead and increased by one (as is the
standard behavior).
在最后一句中,写着
If it is not set or its value is not convertible to a positive integer (without
loosing precision), the value of the previous build will be taken instead
and increased by one (as is the standard behavior)
所以,通过这个我构建了一个注入值 BUILD_YEAR
和 BUILDS_THIS_YEAR
的 jar,按预期工作(jenkin 说 Building my_app_2019.1-SNAPSHOT
)。在那之后,我删除了假设它们会被选中的变量,但不幸的是詹金说 Building my_app_${BUILD_YEAR}.${BUILDS_THIS_YEAR}-SNAPSHOT
.
没有关于此的相关文档,或者我可能遗漏了一些非常明显的东西
问题
如何确保这些 var
被正确地注入到我的 Maven 构建中?或者更确切地说,我如何使用插件填充值?
这不是 jenkins 管道,它是一个简单的 jar 构建。
错过设置 Create a formatted version number
如下:
已根据上图更新并将命令更改为 -Dproject.version=${VERSION_NUMBER}-SNAPSHOT
...瞧!!!!!!
上下文:
我们构建我们的 Maven 应用程序,其中版本号由 build.properties
文件注入。这种方法的问题是对于每个版本,版本号都需要手动 bumped。
在线浏览以解决此问题,我遇到了 version number plugin,它提供了一些很酷的方法来解决此问题。
例如-Dproject.version=${BUILD_YEAR}.${BUILDS_THIS_YEAR}
会为我解决问题
问题
我在设置已定义变量的值时遇到问题
引用文档:
Initialization Values
Before the build is started, the number of builds this year / month / week / day can be specified on the command line or via the job's plugin-configuration web-GUI. If they are specified, then they will override whatever values are currently in production. This allows you to migrate your version number from another system to Jenkins if you choose to do so.Additionally, it is possible to automatically override the number of builds this year / month / week / day with values taken from environment-variables. Instead of just providing a simple number in the form-fields of the job's plugin-configuration which overrides the value for the next build (as described above), you can instead provide an environment-variable whose value will be extracted and used during the next builds. If it is not set or its value is not convertible to a positive integer (without loosing precision), the value of the previous build will be taken instead and increased by one (as is the standard behavior).
在最后一句中,写着
If it is not set or its value is not convertible to a positive integer (without
loosing precision), the value of the previous build will be taken instead
and increased by one (as is the standard behavior)
所以,通过这个我构建了一个注入值 BUILD_YEAR
和 BUILDS_THIS_YEAR
的 jar,按预期工作(jenkin 说 Building my_app_2019.1-SNAPSHOT
)。在那之后,我删除了假设它们会被选中的变量,但不幸的是詹金说 Building my_app_${BUILD_YEAR}.${BUILDS_THIS_YEAR}-SNAPSHOT
.
没有关于此的相关文档,或者我可能遗漏了一些非常明显的东西
问题
如何确保这些 var
被正确地注入到我的 Maven 构建中?或者更确切地说,我如何使用插件填充值?
这不是 jenkins 管道,它是一个简单的 jar 构建。
错过设置 Create a formatted version number
如下:
已根据上图更新并将命令更改为 -Dproject.version=${VERSION_NUMBER}-SNAPSHOT
...瞧!!!!!!