Can I easily change build agent assigned across and entire project in bamboo.

lance_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2020

Going to be switching to newer build servers and want to be able to setup the new machine, and bamboo build agents then assign every build thats done on machine1 to machine2.

 

I am using a custom key like agent name ='machine name" so it would be a bulk change of agent name,etc.

 

 

1 answer

1 vote
Gerhard Forster
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 13, 2020

Hello there.

Thanks for your question that might also be interesting for other Bamboo users.

Let me start with a general overview of Bamboo's agent assignment options.

Dynamic assignment works via setting an agent capability and specifying the appropriate reqirement in a build plan's job. Effectively a requirement can be regarded as a must-have capability of a build plan on job level. If both match for one agent, that agent can be selected by Bamboo Server to run that build's job.

Find this process outlined in the following KB:

https://confluence.atlassian.com/bamboo/about-capabilities-and-requirements-289277171.html 

Alternetively, Bamboo offers the option to explicitly dedicating an agent, be it local, remote or even elastic, to a build project, plan or job. This represents a fixed assignment. Find the below KB as a great reference for doing so.

https://confluence.atlassian.com/bamboo/dedicating-an-agent-629015108.html 

Clearly, you can combine both strategies so to permit best and most flexible usage of your agent pool for your build plans, jobs and tasks. That said, when adding new agents which are supposed to run builds, you can utilize the above simply via Bamboo's UI.

Now we understand that you'd like to automatize agent switching from old to new agents. One sleek way of doing so using Bamboo UI might be the following:

  1. Add each of your new agents to Bamboo so that it's visible for a Bamboo Admin under Cog >> Overview >> Agents
  2. On the "Agents" page, click on one of these new agents and on the appearing Agent summary >> <agent name> page, define e.g one or more "Agent-specific" or a "Shared" custom capabilities. Each of these are actually key-value pairs. For example, you may want to create key "agent_selector" and set it a a value like "LinuxAgent10". You might want to add others charaterizing your agent such as "performance_key" with a set of values, and more.
  3. Repeat the above for all your new agents, setting capabilities as needed.
  4. When done, navigate to your build plan(s), under Plan configuration select the wished job(s) and there get on tab "Requirements". Use any of the previously set custom capabilities with "exists", "equals" or "matches" and possibly combine those with other capability types existing for the new agents, like Exceutables, Git or other SVCs, Docker, etc.

The above approach should help you replace old by new agents with little effort.

With regards to "configuration per code", you may consider defining requirements for a build plan's job or task within its Bamboo Java or YAML Specs. Find this illustrated, also per examples, in section "Requirements" of KB

https://docs.atlassian.com/bamboo-specs-docs/7.0.2/specs.html?yaml#requirements 

Besides, Bamboo's REST API allows to dedicate a build project, plan or job to an agent per the following endpoint

/agent/assignment?executorType&executorId&assignmentType&entityId

using the POST method. The DELETE method may be used to remove a dedication and per GET you can query for existing ones.
For deployment environments exist basically the same, though using two different REST endpoints for that.

Please find all REST details in our

https://docs.atlassian.com/atlassian-bamboo/REST/6.8.1/ 

Hope this helps. Please let us know if there is more that we can assist you on.

Thanks and cheers.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events