Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I check to see if running as a remote agent or local?

Jason Huntley
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.
October 10, 2013

If seen this in your source code base:

private boolean isOnLocalAgent() {
        return !(buildDirectoryManager instanceof RemoteBuildDirectoryManager);
    }

However, it doesn't seem to work from a remote agent. I'm assuming this is switched on the server side, to tell the build processor where the build is occuring.

I need to figure out how to check if my build is being run from a remote agent vs local.

This check needs to occure within a standard CustomBuildProcessor:

public class MyProcessor extends BaseConfigurableBuildPlugin implements
    CustomBuildProcessor {

    private BuildDirectoryManager buildDirectoryManager = null;

        public void
                    setBuildDirectoryManager(BuildDirectoryManager buildDirectoryManager) {
        logger.debug(String.format(
            "setBuildDirectoryManager: setting build directory manager, %s..",
            buildDirectoryManager.toString()));
        this.buildDirectoryManager = buildDirectoryManager;
    }

    private boolean isOnLocalAgent() {
        return !(buildDirectoryManager instanceof RemoteBuildDirectoryManager);
    }

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 15, 2013

Try using: com.atlassian.bamboo.agent.AgentTypeHolder#get

0 votes
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 14, 2013

Our implementation of isOnLocalAgent() is admitedly hacky but it works both on local and remote agents. For example, our git plugin relies on it. If it doesn't work for you I suggest looking at Spring injection in your plugin. Do you have all the "component-import" statements in atlassian-plugin.xml ?

TAGS
AUG Leaders

Atlassian Community Events