Question

I am using a TeamCity Trigger to build everything once there is a commit to svn on the branch. Once successful it send an email notification which includes the VCS changes that caused this build to be triggered. From a TeamCity perspective this works fine.

There are now multiple members on the team who do not have permissions to TC and cannot set up notifications. With this I have decided to use NAnt's <mail> to send this notification along with the Build number using "${environment::get-variable('BUILD_NUMBER')}" . This works fine within teamcity. However, I also need to send the Changes that triggered that build in the message of that email notification.

Currently TeamCity formats the VSC changes to the email like this:

     Changes included (1 change).
     Change 10433 by John Doe (4 files): Issue#245 - Issue description

I am looking to generate the same changes from TeamCity using NAnt. TeamCity defines this format in the common.flt file using the build_changes bean.

**Changes included (${changesLink})
  Change ${mod.displayVersion} ${pers} by ${mod.userName} (${modLink}):
          <i>${description?trim}</i>**

How can I use this within my NAnt messages? Since TeamCity already know what svn change triggered the build, it will be better to get this change and add it to my NANT messages for the email. Is there is simple way to do this?

Was it helpful?

Solution

I've never used NAnt but can offer two other solutions...

1) Create an email mailing list and add all the people that require it to the list.

Then create a teamcity user for with its email to to the mailing list and setup the required notifications to that user.

Restrictions to this is you have to create a user per mailing list which can eat up the licenses.

2) You can use the TeamCity REST API to get that information from the running build. Use %teamcity.build.id% which will return the build id and perform the following lookup:

/httpAuth/app/rest/changes?build=id:%teamcity.build.id%

Which will return all the changes for the build which will like:

<changes count="3">
   <change href="/httpAuth/app/rest/changes/id:217404" id="217404" version="b6b97a0d7789d97df6df908ab582ebb723235f43" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217404&personal=false"/>
   <change href="/httpAuth/app/rest/changes/id:217403" id="217403" version="064ecef5552ec2fb7875d7c26fe54cdf94b67bec" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217403&personal=false"/>
   <change href="/httpAuth/app/rest/changes/id:217402" id="217402" version="9bc3a34c952059bbfc7bebeb79ba5a3c894ef555" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217402&personal=false"/>
</changes>

Then loop through the href url results for each of the <change> elements. Which return something like:

<change date="20130918T133404-0600" username="welsh" href="/httpAuth/app/rest/changes/id:217397" id="217397" version="51e925e354a83deccde881b30a76974b2ff745f4" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217397&personal=false">
  <comment>
    My comments are here
  </comment>
  <files>
    <file before-revision="90acd4da1972814094c22e3020c5073521a7b640@141323126c0" after-revision="51e925e354a83deccde881b30a76974b2ff745f4@1413290abe0" file="grails-app/views/layouts/global.gsp" relative-file="grails-app/views/layouts/global.gsp"/>
  </files>
  <user href="/httpAuth/app/rest/users/id:1" id="1" name="Welsh" username="welsh"/>
</change>

And use that to build your email to who you email to whoever which is more work to create initially but more freedom on who you email without eating up licenses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top