How do I Setup an Agent Requirement in TeamCity that detects if an Application is installed?

continuous-integration, teamcity

Solution

You can build a simple agent plugin. Here are a few suggestions:

- Extend `AgentLifeCycleAdapter` and implement `agentInitialized` method

- Implement logic of detection the necessary application (for example based on some file existence) inside `agentInitialized` method

- Use `agent.getConfiguration().addConfigurationParameter()` to report agent parameter to the server

If your detection logic can be implemented through file detection, you can use FileWatcher to monitor specific files and report parameters based on them even without restart of the agent

Problem

I have a build environment with multiple agents. I would like to set up an Agent Requirement in my build that detects if certain software is installed. In some cases I can look in the env.Path for a particular string. But some software doesn't modify the Path. I realize that after I install the software i could edit the BuildAgent.properties file to set a particular property, but I'd like it to be more automatic. The specific instance is I have a build that uses MSDeploy to deploy websites, but it won't work if MSDeploy isn't installed. How can I specify in my build that I need an Agent that has MSDeploy installed?

Original source