通过 Maven 发布 POM 并插入构建版本信息
我正在通过 TeamCity/Git 构建 Maven 项目,并尝试在 pom.xml 中插入 TeamCity 构建号,该构建号在成功构建后发布到我的存储库。不幸的是,我无法确定如何发布插入替换的 pom.xml 。
我的 pom.xml 包含以下信息:
<version>${build.number}</version>
其中 build.number 由 TeamCity 提供。一切构建都可以,如果(比如说)build.number = 0.1,那么部署是一个 pom.xml
到 0.1 的目录。一切都很好。
但是,部署的 pom.xml 是没有进行替换的 pom.xml
。即 Maven 正在使用带有适当替换的 pom.xml
运行,但部署了初始版本,因此我得到了
<version>${build.number}</version>
最终的pom.xml
中的构建版本号?
I'm building Maven projects via TeamCity/Git and trying to insert the TeamCity build numbers in the pom.xml that gets published to my repository upon a successful build. Unfortunately I can't determine how to publish a pom.xml with the substitutions inserted.
My pom.xml contains info like:
<version>${build.number}</version>
where build.number is provided by TeamCity. That all builds ok, and if (say) build.number = 0.1, then the deployment is a pom.xml
to a directory with 0.1. All well and good.
However, the pom.xml that is deployed is the pom.xml
without the substitutions made. i.e. Maven is running with a pom.xml
with appropriate substitutions, but deploys the initial version and so I get
<version>${build.number}</version>
in the final pom.xml
. How can I get the build version number in the pom.xml
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不会使用这种方法,因为它使得在不提供
build.number
属性的情况下无法构建从 SCM 签出的项目。我认为这不是一件好事。也许我错过了一些东西。实际上,我不明白您想要确切实现什么(例如,为什么不在清单中写入内部版本号)。但是,根据 Teamcity 网站上的 Maven 功能:
这难道没有帮助吗? 此处还有另一个关于此问题的帖子。
I wouldn't use this approach because it makes building a project checked out from the SCM not possible without providing the
build.number
property. I don't think that this is a good thing. Maybe I'm missing something though.Actually, I don't get what you are trying to achieve exactly (why don't you write the build number in the manifest for example). But, according to the Maven Features on the Teamcity website:
Couldn't that be helpful? There is another thread about this here.
尝试使用 maven- 的 generateReleasePoms 属性realease-plugin,也许会有一点帮助。
Try to use generateReleasePoms property of maven-realease-plugin, maybe that helps a little.