How to get previous revision identifier before this run's current revision identifier


For an agent plugin that I'm working on, I not only need a current source control revision identifier (for svn, it's a straight-up integer that can be acquired in a number of ways off of the runnerContext or any of its sub-objects), but I need the revision number of the last successful prior build that that agent ran.

For example, under an svn-supported teamcity environment, an agent is run and the current svn revision number is 62.  The build finishes successfully.  Three changelists are submitted, increasing the revision number to 65.  When the build is run again, I'd like to know, before any of the build actions are taken (preferably [beforeBuildStart (sic) would be a good hook]), what the most recent revision id is against which a successful build was run (and the correct answer 99 times out of 100 would be 62).

Since you will ask if I don't tell ( ;-) ), I need to pass the revision range (62:65) to an external tool that will perform a static code analysis using the revision range.

There will be a follow-up question momentarily asking how to get TeamCity to recognize external libraries wrt Spring.

Thank you in advance,

1 comment
Comment actions Permalink

Hi Nic,

The agent does not store that kind of information, so you have two options here:
- query the server, e.g. via REST API for the previous successful build and it's revision. You can even get the data about the builds run not ont he same agent. However, the REST communication has to be implemented from scratch, as you could not benefit from that you run as an agent plugin.
- make your plugin store the data on the agent: after each finished build, get the data and store in in some plugin-specific format on the agent

The task seems not very common as usually the tools are integrated inside TeamCity build as opposed to sending revisions to another system.


Please sign in to leave a comment.