4 comments
Comment actions Permalink

Hello,

  You may probably want to take a look at TW-716 .

   Kind regards,
   KIR

0
Comment actions Permalink

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.

0
Comment actions Permalink

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

0
Comment actions Permalink

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:

<build>
     <finalName>${project.artifactId}-${project.version}-r${build.vcs.number}</finalName>
</build>


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:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-jar-plugin</artifactId>
          <configuration>
               <archive>
                    <manifest>
                         [ PUT YOUR REAL MANIFEST CONFIG HERE ]
                    </manifest>
                    <manifestEntries>
                         <Implementation-Build>${build.vcs.number}</Implementation-Build>
                    </manifestEntries>
               </archive>
          </configuration>
</plugin>


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:

-Dbuild.vcs.number=SOME_BUILD_ID


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.

0

Please sign in to leave a comment.