通过 Maven 发布 POM 并插入构建版本信息

发布于 2024-08-19 14:54:41 字数 601 浏览 3 评论 0原文

我正在通过 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。如何获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巴黎盛开的樱花 2024-08-26 14:54:41

我不会使用这种方法,因为它使得在不提供 build.number 属性的情况下无法构建从 SCM 签出的项目。我认为这不是一件好事。也许我错过了一些东西。

实际上,我不明白您想要确切实现什么(例如,为什么不在清单中写入内部版本号)。但是,根据 Teamcity 网站上的 Maven 功能

默认情况下,它还会使 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:

By default, it also keeps TeamCity build number in sync with the Maven version number (...).

Couldn't that be helpful? There is another thread about this here.

宫墨修音 2024-08-26 14:54:41

尝试使用 maven- 的 generateReleasePoms 属性realease-plugin,也许会有一点帮助。

Try to use generateReleasePoms property of maven-realease-plugin, maybe that helps a little.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文