Remote Agent registered events

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.

1 answer

1 accepted

0 votes
Accepted answer

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

63 views 3 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you