Additional Build Configuration Module

Available:

Bamboo 2.7 and later

On this page:

Purpose of this Module Type

Additional Build Configuration Module allows developers to register additional configuration UI on the Miscellaneous tab of the Configuration of a Job or Plan.

Configuration

The root element for the Additional Build Configuration module is additionalBuildConfigurationPlugin. It allows the following attributes and child elements for configuration:

Attributes

Name

Required

Description

Default

class

(tick)

The class which implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin. See the plugin framework guide to creating plugin module instances.

key

(tick)

The unique identifier of the plugin module. You refer to this key to use the resource from other contexts in your plugin, such as from the plugin Java code or JavaScript resources.

<component-import key="appProps" interface="com.atlassian.sal.api.ApplicationProperties"/>

In the example, appProps is the key for this particular module declaration, for component-import, in this case.

N/A

name

The human-readable name of the plugin module. Only used in the plugin's administrative user interface.

Elements

The table summarises the elements. The sections below contain further information.

Name

Required

Description

Default

description

The description of the plugin module. The 'key' attribute can be specified to declare a localisation key for the value instead of text in the element body. Use this element to describe the section.

resource

(tick)

Using the "edit" and "view" attributes it is possible to provide a custom template for editing and viewing your custom plugin configuration

Interface

Additional Build Configuration modules must implement the MiscellaneousBuildConfigurationPlugin interface and extend BaseBuildConfigurationAwarePlugin.

Example

Plugin Descriptor

Here is an example atlassian-plugin.xml file containing a Post Chain Index Writer Action module:

 
<atlassian-plugin name="Hello World" key="example.plugin.helloworld"> 
  <plugin-info> 
    <description>A Additional Build Configuration Module module type test</description> 
    <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/> 
    <version>1.0</version> 
  </plugin-info> 

  <additionalBuildConfigurationPlugin key="concurrentBuild" name="Concurrent Build Configuration"
        class="com.atlassian.bamboo.build.configuration.ConcurrentBuildsPlanConfigurationPlugin">
    <description>Plugin to configure maximum number of concurrent builds for a plan</description>
    <resource type="freemarker" name="edit" location="build/concurrent/editConcurrentBuildsConfigForPlan.ftl"/>
    <resource type="freemarker" name="view" location="build/concurrent/viewConcurrentBuildsConfigForPlan.ftl"/>
  </additionalBuildConfigurationPlugin>
</atlassian-plugin> 

Freemarker Edit and View Templates

Example "edit" template:

[@ui.bambooSection titleKey="build.concurrent.title"]
    [@ww.checkbox labelKey='build.concurrent.overrideDefault'
                  name='custom.concurrentBuilds.overrideNumberOfConcurrentBuilds'
                  toggle='true' /]

    [@ui.bambooSection dependsOn='custom.concurrentBuilds.overrideNumberOfConcurrentBuilds' showOn='true']
        [@ww.textfield labelKey='build.concurrent.maxnumber'
                       name='custom.concurrentBuilds.numberOfConcurrentBuilds'
                        /]
    [/@ui.bambooSection]
[/@ui.bambooSection]

Example "view" template:

[#if action.concurrentBuildsEnabled && planLevelConcurrentBuildConfig.defaultOverridden]
    [#assign labelValue]${planLevelConcurrentBuildConfig.effectiveNumberOfConcurrentBuilds}[#if !planLevelConcurrentBuildConfig.defaultOverridden] (${action.getText('global.default.used')})[/#if][/#assign]
    [@ww.label labelKey='build.concurrent.maxnumber' value='${labelValue}' /]
[/#if]

Display Conditions

By overriding isApplicableTo it is possible to control the conditions on which the configuration UI is shown. One typical implementation is to check and only display on a plans type.

To display on all TopLevelPlan's (Chains and Builds):

    public boolean isApplicableTo(@NotNull Plan plan)
    {
        return plan instanceof TopLevelPlan;
    }

To display only on Jobs:

    public boolean isApplicableTo(@NotNull Plan plan)
    {
        return plan instanceof Job;
    }
Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport