8
votes

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 ?

2
Why the downvote for the question?Brian Agnew

2 Answers

3
votes

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.

1
votes

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