maven 发布插件 - 操作项目发布版本 [英] maven release plugin - manipulating project release version
问题描述
我正在尝试在 Jenkins 中配置一个带有自定义发布版本的 Maven 发布版本,其中包含发布版本的分支.
I'm trying to configure in Jenkins a maven release build with customized release version that includes the branch from which the release was made.
看起来像这样:
release:prepare -DreleaseVersion=${project.version}-${GIT_LOCAL_BRANCH}-Release release:perform
release:prepare -DreleaseVersion=${project.version}-${GIT_LOCAL_BRANCH}-Release release:perform
一切正常,除了基于 pom 计算的 'project.version' 占位符包含 '-SNAPSHOT' 后缀.
everything works fine, except that the 'project.version' placeholder, which calculated based on the pom, contains the '-SNAPSHOT' postfix.
是否有其他占位符可以在没有 '-SNAPSHOT' 的情况下使用它?我知道默认情况下 Maven 发布插件会设置正确的版本 - 只有我想操纵该值.
is there other placeholder which I can use to get it without the '-SNAPSHOT'? I know that the maven release plugin, by default, will set the right version - only I want to manipulate that value.
推荐答案
查看官方文档 https://maven.apache.org/maven-ci-friendly.html.
从 3.5 开始,maven 支持 3 个属性:${revision}
、${sha1}
和 ${changelist}
.所以你可以使用类似
There are 3 properties maven supports since 3.5: ${revision}
, ${sha1}
and ${changelist}
. So you can use something like
<version>${revision}${changelist}</version>
...
<properties>
<revision>1.3.1</revision>
<changelist>-SNAPSHOT</changelist>
</properties>
并调用它
release:prepare -DreleaseVersion=${revision}-${GIT_LOCAL_BRANCH}-Release
但是 maven-release-plugin 不能很好地与 CI 友好版本一起使用.阅读:它可能会覆盖版本标签中的占位符.所以最后你可能只是通过 bash 命令操作 -SNAPSHOT 字符串.
But the maven-release-plugin does not work nicely together with the CI friendly versions. Read: it will probably overwrite your placeholders in the version tag. So in the end you might just manipulate the -SNAPSHOT string via bash commands.
这篇关于maven 发布插件 - 操作项目发布版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!