how to trigger an action before the build start

I have written a plugin to provision an agent machine and return the machine name.  I want to find a way to trigger this action before the build start and wait for the agent machine name was returned.  I'm new to TeamCity and please give me some ideas on how to do this.  Also, I want to display a list of build configurations on the plugin page and please let me know which API should I use to get a list of build configurations.  Thanks very much for the help!

3 comments
Comment actions Permalink

Hi Lin,

TeamCity has support for Amazon EC2 which spins up new instances when there are compatible builds int he queue and shuts them down after idle timeout.
The integration is implemented as a plugin and there is specific support in the core for such plugins.
There is also an open-source plugin based on VMWare player software which provides alike functionality.

It might make sense to study plugin's sources to figure out how it works and decide whether the approach suits your needs or not.

If you decide to go another way, I'd suggest to add a listener for BuildServerListener.buildTypeAddedToQueue event and schedule an agent machine start in it (the listener code should not perform and long operations itself).

As to getting all build configuraitons, you can getn an instance of ProjectManager via Spring (requesting it in the constructor of your Spring-configured bean) and then use it's methods, like getAllBuildTypes.

BTW, if you plugin can be of use to other users, please consider making it public.

Message was edited by: Michael Kuzmin

0
Comment actions Permalink

Hi Yegor,

We are using the BuildServerListener as you mentioned. The link you provided did not work. Is there another example of how to add the listener?

0
Comment actions Permalink

I've fixed the link above.

0

Please sign in to leave a comment.