Can maven reference TC build-numbers within pom.xml?
We have maven builds executed via TeamCity, but I'd like Maven to grok the version-number from the Team-City build. Can anybody tell me where I should be looking for this? Can't find anything in http://www.jetbrains.net/confluence/display/TCD/maven
Thanks,
--kov
Please sign in to leave a comment.
Hello,
You may probably want to take a look at TW-716 .
Kind regards,
KIR
Thanks Kirill, actually all I needed was the more traditional TC method -- putting ${build.number} in the pom.xml and letting TeamCity set the system.property for it. But this other stuff is useful to know and well appreciated.
Hi,
What exactly did you do to get this working.
Did you include the "build-server-plugin-mvn-build-number.xml" in TeamCity\WEB-INF\classes\META-INF as described in http://jetbrains.net/tracker/issue/TW-716 and then entered "pom" as build number format in teamcity project?
Do I need to include ${build.number} in my project's pom.xml?
Does this also include a file in the build containing the TeamCity snapshot's build number?
Regards,
Manfred
Manfred,
I think there are two different properties you can reference in you pom.xml:
${build.number}
and
${build.vcs.number}
TeamCity will set them at the start of a build. I use ${build.vcs.number} and like the way it works. You may need to set the TeamCity Build number format to {build.vcs.number}. I'm not positive, but using {build.vcs.number} as the build number format keeps everything well organised.
You can set your artifact file name by adding something similar to the following to your pom.xml:
I also find it useful to include the VCS number in my MANIFEST.MF files. You can do this in the maven-jar-plugin config:
Then when your build runs on TeamCity the build server will set build.vcs.number to the current revision of your VCS. You may also need to set TeamCity to have code checked out on the build client rather than the build server (I'm not positive about this - I used checkout on client). If you build your module somewhere other than the TeamCity server the build.vcs.number will be null. You can set it at runtime using:
Using IntelliJ IDEA 8.x you can go into Project Settings --> Maven --> Runner and add the build.vcs.number property. For example, on my development machine I set the property to DEV-Ryan. That way if I build from my development machine I get an artifact that looks something like myArtifact-1.0-SNAPSHOT-rDEV-Ryan.jar. If a build comes from my TeamCity server I end up with an artifact that looks something like myArtifact-1.0-SNAPSHOT-r12345.
I hope that's the info you were asking for and that it helps. I just started using Maven last week, so I'm still learning, but the above info should be accurate.