How to configure an agent requirement in TeamCity that determines if an application is installed?

I have a build environment with several agents.
I would like to configure Agent Requirement in my assembly, which determines if certain software is installed. In some cases, I can look in env.Path for a specific line. But some software does not change the way.

I understand that after installing the software, I can edit the BuildAgent.properties file to set a specific property, but I would like it to be more automatic.

Specific instance: I have an assembly that uses MSDeploy to deploy websites, but it will not work if MSDeploy is not installed. How can I indicate in my assembly that I need an agent on which MSDeploy is installed?

+7
continuous-integration teamcity
source share
3 answers

You can create a simple agent plugin. Here are some suggestions:

  • Extend AgentLifeCycleAdapter and implement the agentInitialized method
  • Implement the detection logic of the required application (for example, based on some file existence) inside the agentInitialized method
  • Use agent.getConfiguration().addConfigurationParameter() to send the agent to the server

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

+3
source share

As far as I know, agent requirements work simply by checking for either the presence or the value specified in the agent parameter. As you say, this requires editing the <agent home>/conf/buildAgent.properties configuration file either manually or in some automatic way.

In terms of automation, you can use the build configuration approach, which acts as the agent boot agent; that is, an assembly that runs for all agents (scheduled overnight / manually) and supports assembly agent settings in the <agent home>/conf/buildAgent.properties depending on the specific conditions of the agent. Something like (pseudo):

if [ exists /path/to/MSDeploy ] then echo MSDeployExists to buildAgent.properties

This is due to a large disclaimer; I have not tried this myself, and I believe that the agent will automatically restart depending on the changes to this file, so there may be problems editing this file automatically. But this is a potential solution to maintain your requirements in a centralized way, and if it works then it works fine. I use a similar approach for self-customizing custom assembly scripts for all agents to increase the already rich feature set in TeamCity.

+2
source share

I agree with SteveChapman's answer. It is clear that you can check environment variables (outputs, contains, starts with, etc.). TeamCity knows about the .NET versions installed on the agent (as well as in Visual Studio and the VS SDK). However, I can not find anything that would be equivalent to the possibility of a "test path".

The sure way to know is to add the agent parameter through the configuration file <agent home>/conf/buildAgent.properties .

+1
source share

All Articles