How to prevent deployment plans to run on certain agents?
Asked by Manuel Mall:

The relationship between build plans and agents can be managed through capabilities and fine tuned using custom capabilities. These features don't seem to exist for deployment plans.

We have Linux and Windows based agents for building. However, for deployment we want to only use the Linux based agents. How can we prevent deployment plans to run on the Windows based agents? And no - dedicating agents just to deployment plans is not feasible. The Linux agents must stay available for running build plans.


Answers:
author: Gretchen
body: You should be able to define a capability - a custom executable that exists only on the linux agents. This can be as simple as a shell script that does nothing. Just make sure that it exists in the same path and is executable (which may or may not truly be necessary but seems like it would throw an error if the script wasn't executable). I have a batch file on my local agents that prints the current date to the screen to restrict the build to a local agent (deployment plans should not be any different as you just insert a new task that uses the shell script). If the shell script exists on the server it will be available as meeting the requirements of the deployment plan. You'll need to add it into each stage though. A stage will revert to the next available agent even if the first stage is restricted via capabilities.

comments: author: Manuel Mall
body: got it - bit clunky but workable

Thanks


author: Swift Capital
body: We're also doing this. Need to be able to specify requirements on Deployment plans.


author: Swift Capital
body: <https://jira.atlassian.com/browse/BAM-13499>


author: Raj Prasad
body: see [Requirement for Deployments](https://marketplace.atlassian.com/plugins/com.atlassian.bamboo.plugin.requirementtask)

This plugin fixes the issue.


author: David Armitage
body: Same as Joe, I can exert no influence on the choice of agent for the deployment project, despite independently trying same.

Added comments to [](https://jira.atlassian.com/browse/BAM-13631)<https://jira.atlassian.com/browse/BAM-13631>


author: Joe Levis
body: Actually, I just tried what Gretchen suggested and it still doesn't work.

@ Manuel - were you able to get the workaround to work as mentioned by Gretchen?

Here's what I did:

1) Added new executable capability (points to a dummy script) to the agents I want deployments to run on.

2) Added a Command task to a deployment project stage to run the newly-defined custom executable.

...and Bamboo is still showing all agents as capable of running the deployment. Hm...? I've confirmed the one agent I don't want deployments running on doesn't have the executable capability. I've also run the deployment just to see if it uses the excluded agent, and it did after a couple runs.

Any thoughts?

@Gretchen, am I missing something?

comments: author: ErbC
body: Nope, this is a bogus solution. It does not restrict what agents a deployment can run on, it just makes the deployment fail on certain agents.


author: ErbC
body: Actually it might work in certain Bamboo versions. But the latest as of this writing gives you a better solution, using capabilities directly.


author: Joe Levis
body: If I may jump in...I would say this isn't a scalable solution, especially when you have over 100 deployment projects with multiple environments in each.

In our case, all of our agents are linux servers, with the exception of a mac mini that is designated for ios builds. I've been trying to figure out how to make sure deployments aren't run from the mac mini. Adding a dummy executable task to all of our deployment projects would be a headache. Is there any talk about adding the capability to exclude specific agents from being used as deployment servers?

comments: author: Manuel Mall
body: I fully agree with your sentiments. The problem as I see it is that Deployment Plans are currrently gimped versions of Build Plans and lack some of the important features of Build Plans like stages and jobs and custom capabilities. For example for us a full deployment means updating a mix of environments (Windows and Linux) but a Deployment Plan can't deliver that as it has no stages that can run on different agents depending on capabilities. Build Plans can do that but Deployment Plans can't. I have no idea why Atlassian didn't make the full power of Build Plans available for Deployment Plans as obviously the infrastructure is already in place.


author: Timothy
body: Create a custom requrirement on the agent that you want to restrict it too. I can be anything that you want to define (e.g. the name of the build project).

Then for each job, add that custom requirement to it to force it to use that agent only.