How to set agent compatible configurations based on a rule

We have one agent dedicated to performing auto deployments. We don't want this agent to get backed up running other builds, and it's the only agent running with the appropriate account that has security access to do deployments. So we have requirements in the auto deploy configurations that specify it has to be run on this agent, and then we have requirements on the agent that specify that only the auto deployment build configs can run.

All that is fine, except that every time we make a new branch of our applications, we get a new set of project configurations with slightly different names (eg Sprint 29 Release AutoDeploy) etc. It would be great to be able to configure this agent to run any build with "AutoDeploy" in its name, or similar tokens.

Is there a way to achieve this?

13 comments
Comment actions Permalink

I don't know if I get your point. But I usually solve this problem by a Configuration Parameter.

For example you could add a line to your buildagents config file under <BuildAgent>/conf/buildAgent.properties:

support.deployment=true



Then set an Agent Requirement on your build configuration like

support.deployment equals true



Then this build can only run on agents with the appropriate parameter.
0
Comment actions Permalink

Hi Timo, thanks for your answer.

The problem isn't getting the builds to run on the agent, the problem is getting the agent to only run deployment related builds. To give you an idea, the TeamCity build configurations for one of our our projects looks sort of like this:

Some Project
     1. Compile
     2. Unit test
     3. Integration test
     4. Package
     5. Deploy to dev environment

The builds flow through the configurations from 1-5 using dependencies. We have 6 applications using this structure, and each time we release, we take a branch, so we get 6 new projects called "Some Project Sprint 29 Release", etc.

The Deployment step can only run on one of our agents. We've got this sorted out fine using agent requirements. However we want to make sure this agent doesn't pick up non deployment related builds so that it doesn't prevent deployments from happening while it's running something that any other agent could run. The only way we can see to achieve this is to change the Compatible Configurations for the agent to "Run selected configurations only", and then specifically select all the Deployment configurations.

But every time we branch, we have to go and add all the new deployment configurations for the new branch, which is a step that's usually forgotten until someone says "Why are none of the deployments working for <xyz> branch?"

Instead of specifically selecting build configurations in the agent's list of compatible configurations, if we could specify "Any configuration whose name contains 'Deploy'", our problem would be solved. But I can't see a way to do that - am I missing something?

Does that make it clearer?

0
Comment actions Permalink

Do you have a dedicated build configuration for the deployment step?

0
Comment actions Permalink

Yes, sorry if that wasn't clear - the steps I listed above are each separate build configurations.

0
Comment actions Permalink

Why can't you set on the fifth (deployment) an Agent Parmater like "only run on agent 1"? (teamcity.agent.name equals deployBuildAgentName)

0
Comment actions Permalink

Hi Timo,

There are two factors here:

1. Which agents will the deploy build run on
2. Which build configurations will the deploy agent run

Your suggestion solves point 1, which we've got going with no problems. The problem I'm talking about is problem 2.

We don't want the single deploy agent to be running just any build configuration that comes along, because we only have one agent for deploying and many for all the other builds. If the deploy agent runs other builds, deploys will queue up waiting for it to run builds that could have run on any other agent.

So we want a way to configure the agent to only run deploy builds. It seems the only way to do this is to specifically choose what builds the agent can run. I'll try pasting a screenshot to show what I'm talking about:


teamcityagentconfiguration.JPG

The problem we're having is that when we create a new branch for a release, we get a whole bunch of new projects specific to the branch. We then have to go back into this screen and add all the new deploy configurations. If we could just specify to the agent to run any configurations that have "Deploy" in their name then we wouldn't have to do this. Is there a way of doing that?

0
Comment actions Permalink

Hi Niall,

alright, I think I got the point now. One solution could be to use the parameter mentioned above. But you would have to declare all other build configurations as not runnable on this agent. But then, on times not deploying, you would have one agent sleeping.

However, I think TeamCity priorizes builds higher, if they can only run on a specific build agent. At least, that is, what I experience in our scenario. Would be good to hear a word from JetBrains how this algorithm works.

Is the solution acceptable or do your branches generate a whole bunch of new build configurations each time you branch?

0
Comment actions Permalink

Hi Timo, it's as you say at the end. Every new branch generates a new  set of build configurations, some of which are deployment configurations,  some are not.

When setting agent requirements on the build configurations, we can use rules that can check whether properties on the agent contain certain values, etc. If we could do the same on the configuration of the agent itself, it would be helpful but it's sounding like there's no way to do it.

0
Comment actions Permalink

What about a Remote-Run-Trigger? You could tell the trigger, that the branch name needs to be something like scm:/YourProject/branches/Deploy*

0
Comment actions Permalink

Hi Timo,

Unfortunately we're using SVN which isn't  supported by that trigger. I'm not sure how it would help though - we  need a way to change what builds an agent runs, not what agents a build runs on.

0
Comment actions Permalink

Hi Niall

In upcomming version 7.0 you'll be able to update list of agent's compatible configurations on project or build configuration clonning:
Capture.PNG

Michael

0
Comment actions Permalink

Hi Michael,

I guess that would solve our problem. However being able to have rules for agents' compatible configurations would mean that instead of having to specify approximately 25 build configurations that we want this agent to exclusively run, we could just have one single rule that picked up on a part of the name. If there's any chance of adding that feature, it would be great!

0
Comment actions Permalink

Could you add this feature request to our tracker please.

0

Please sign in to leave a comment.