I'm trying to write a bamboo plugin that signals when a remote agent registers. I can successfully get an AgentConfigurationUpdatedEvent to fire but I'm unable to get the agent name and more importantly for me, the capabilities.
My code is:
public class AgentRegisteredListener implements HibernateEventListener { private static final Logger log = Logger.getLogger(AgentRegisteredListener.class); @Override public Class[] getHandledEventClasses() { return new Class[] { AgentConfigurationUpdatedEvent.class }; } @Override public void handleEvent(Event event) { if (event instanceof AgentConfigurationUpdatedEvent) { AgentConfigurationUpdatedEvent agentConfigurationUpdatedEvent = (AgentConfigurationUpdatedEvent) event; BuildAgent buildAgent = agentConfigurationUpdatedEvent.getBuildAgent(); String capabilities = ""; if (buildAgent != null) { PipelineDefinition agent = buildAgent.getDefinition(); if (agent != null) { CapabilitySet capabilitySet = CabilitySetProvider.getAgentCapabilitySet(agent); for (Capability capability : capabilitySet.getCapabilities()) { capabilities += capability.getKey() + ":" + capability.getValue() + ";"; } } log.debug("AgentConfigurationUpdatedEvent: " + dateFormat.format(date) + " - " + ((buildAgent.getName() == null) ? "null" : buildAgent.getName()) + " - " + buildAgent.getAgentStatus().getLabel() + " - " + capabilities); } else { log.debug("AgentConfigurationUpdatedEvent: null agent returned"); } } } }
The problem is that the buildAgent returned from agentConfigurationUpdatedEvent.getBuildAgent() is always null. Please can someone help me get the agent name and capabilities of a newly registered remote agent.
Thanks.
Hi,
As far as I can tell by quickly scanning Bamboo's source code, getBuildAgent() should not return null.
Which version of Bamboo do you try this with? Could you please try it with the latest (5.1.1) and if it's still doesn't work please open a bug at https://jira.atlassian.com (project name is Bamboo, project key: BAM)
It's not particularly easy for me to try using the latest version at the moment - our remote agents are limited to connecting to our live bamboo instances by the cluster they run on and these servers are both at 4.4.5. We hope to upgrade soon so I'll try this then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.