0

For continuous integration I am using Maven 2 and TeamCity 5.1.2. My builder number is defined by the pattern %maven.project.version%.{0}, and this is exported to Maven build script as ${build.number}

When the build creates the jar file I would like the jar to contain a property file with this information inside:

build.number=#1.1-SNAPSHOT.106

This is so that the build number is available for display etc at runtime.

Paul McKenzie
  • 19,646
  • 25
  • 76
  • 120
  • 1
    Here is almost exactly the same question: http://stackoverflow.com/questions/3532135/using-maven-to-output-the-version-number-to-a-text-file – Sean Patrick Floyd Aug 31 '10 at 15:29
  • almost, but not exactly. The solution in the post referred to by Seanizer gets me a long way down the road. Now I have in my properties file after the build completes: build.number=%maven.project.version%.113. – Paul McKenzie Sep 01 '10 at 08:08

3 Answers3

3

You could have a copy of the property file with a placeholder for the build number

build.number=${build.number}

Than copy with filtering enabled.

sblundy
  • 60,628
  • 22
  • 121
  • 123
1

Based upon the comment, it sounds like %maven.project.version% is not being replaced by TeamCity. You're getting the build job number, but not getting the value for the maven ID.

I would look at potentially doing this in two parts.

Can ${build.number} only contain the actual build number, instead of %maven.project.version%?

If so, you should be able to have your properties file say:

build.number=#${project.version}.${build.number}

In theory that would produce:

build.number=#1.1-SNAPSHOT.106

But not having worked with TeamCity, this is just a theory.

Mike Cornell
  • 5,909
  • 4
  • 29
  • 38
0

Try

build.number=${buildNumber}

where ${buildNumber} is place holder for Maven to add the next number.

Lundin
  • 195,001
  • 40
  • 254
  • 396
Jay
  • 1