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 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,816 views 0 6
Read article

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