Last updated Dec 8, 2017

Accessing Bamboo components from plugin modules

Bamboo is built around Spring, an open-source component framework for Java.

If you are familiar with Spring, then you may only wish to know that Bamboo plugin modules (and their implementing classes) are autowired by name. Thus, if you want to access a Bamboo component from your plugin, just include the appropriate setter method in your implementing class.

If you want to write Bamboo plugins but are unfamiliar with Spring, the rest of this page should give you more than enough information on how to have your plugin interact with Bamboo.

Interacting with Bamboo

When you are writing anything but the simplest Bamboo plugin, you will need to interact with the Bamboo application itself in order to retrieve, change or store information. This document describes how this can be done.

Manager Objects

At the core of Bamboo is a group of "Manager" objects. For example, the buildManager is in charge of Bamboo's build plans, the buildResultsSummaryManager of build results, and so on.

Dependency Injection

Traditionally, in a component-based system, components are retrieved from some kind of central repository. For example, in an EJB-based system, you would retrieve the bean from the application server's JNDI repository.

Bamboo works the other way round. When a plugin module is instantiated, Bamboo determines which components the module needs, and delivers them to it.

Bamboo determines which components a module needs by reflecting on the module's methods. Any method with a signature that matches a standard JavaBeans-style setter of the same name as a Bamboo component will have that component passed to it when the module is initialised.

So, if your plugin module needs to access the buildManager, all you need to do is put the following setter method on your module's implementing class:

1
2
public void setBuildManager(BuildManager buildManager)
{
this.buildManager = buildManager;
}

Manager Classes

There are many managers for different areas of functionality in Bamboo. Not all managers are available on both the application server and any agents that might be running. The following table lists some of the more commonly used ones:

Manager class*

Responsibility

Sample methods

JiraServerManager

Jira Server Connection Details

getDefaultJiraServer()

BuildManager

Build Plans

getBuildByKey(String key), getAllBuildsForRead(), getBuildResults(Build build, Integer buildNumber)

BuildResultsSummaryManager

Build Results

getBuildResultsSummary(Build build, int buildNumber), getLastBuildSummary(String planKey)

BuildExecutionUpdateManager

Build Loggers and other running details to be passed back to the server

getBuildLogger(@NotNull String buildPlanKey)

InstantMessagingServerManager

Connection Details for Instant Messaging Server

getAllInstantMessagingServers(), getInstantMessagingServer(long instantMessagingServerId)

LocalAgentManager

Manages build agents both remote and local from the server

getAllLocalAgents(), getAllRemoteAgents(), createLocalAgent(PipelineDefinition pipelineDefinition), getAgent(long agentId)

*A BuildExecutionUpdateManager class is available on both the application server and agents. All other classes above are available only on the application server.

Note that these are all interfaces. The actual implementation will be injected in your class by Spring, if you include the appropriate setter method in your class as described above.

Do not directly use implementations or cast the injected class to a particular implementation. Implementation classes are subject to change across versions without warning. Where possible, interface methods will be marked as deprecated for two major versions before being removed.

Other classes that can be injected

There are also many other classes available to be injected into you plugin which may make your life easier.

More information

Rate this page: