Clean Up Environment After Stopping Build

We've got a pretty complicated setup going on and our tests have dependencies that are very tied to the system, and if we stop a TeamCity build the environment for our build agent's server isn't guaranteed to be in a good state. Is there any way to run a stopped build callback or guarantee that a cleanup task is executed after someone manually stops a build so that we can ensure that the server returns to a clean state?

Comment actions Permalink


Currently you can only write custom TeamCity Java plugin to perform an action before build stopping.

I also filed a request to allow this without writing a plugin.

Comment actions Permalink


This is the exact type of thing that we need as well.  We have never attempted a Team City plugin so far. I have a few questions.

1 - Can anyone provide a kickstart example of this type of plugin?

2 - We would only want this plugin to clean up after specific build plans on specific agents.  How do we achieve this
Is the plugin automatically deployed to all agents?  Do we use specific properties in the build plan to control how and what the plugin does?

Thanks in advance..

Comment actions Permalink

Provided you have seen the doc, you may chose one of the plugins that have agent part. e.g. XML Test Reporting or Swabra.
You can then extend AgentLifeCycleAdapter and add your logic into beforeBuildInterrupted method.

Plugin is automaticlaly deplouyed to all the agents. You can get the agent name in the plugin (or, better, read environment) and figure out if you need to do anything on the agent.

I fyou need per-build configuration control you can probably add a parameter to it in its settings and then get the parameter's value in the plugin.


Please sign in to leave a comment.