How can I use maven build number as TeamCity build number?

When I set up a default Maven2 project from POM, TeamCity is supposed to use the Maven build number as its own build number (I think). However, this does not work for me, TeamCity simply uses it's own number (1, 2, 3, etc). My POMs have SNAPSHOT version. I would like TeamCity to use the sequence number that Maven attaches a SNAPSHOT artifact (e.g. the number 3 from the following artifact: agents-api-38.0.0-20100112.042101-3.pom). How do I configure this in TeamCity?


On the page it says: "By default, it also keeps TeamCity build number in sync with the Maven version number, although you can disable this synchronization later on".

So apparently this synchronization of maven numbers and teamcity numbers is enabled by default, but I do not see it happening. Where/how can it be configured?


You should include variable maven.project.version into the build number pattern. For example, with pattern %maven.project.version%.{0} your build number sequence would look like

etc., where the final number is the regular TeamCity build number (which can be omitted if you wish).

Note, that maven.project.version is taken directly from the POM, not from deployed artifacts. If the POM has a SNAPSHOT version, maven.project.version will also have "...-SNAPSHOT" value, not "...-20100112.042101-3" which is assigned to an artifact when deploying.


I am using %maven.project.version%.{0}  as the pattern and it works nicely.

I am trying to capture the value in a property file using a <resource> block and filtering.

The property file looks like:


However, after the build the property file looks like:


Where 106 is the correct {0} part of the build number.

The build number is correctly displayed on the projects tab at the end of the build.

The build log says:

Parameter 'build.number=%maven.project.version%.120' is not fully resolved, using as is.

Please sign in to leave a comment.