Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Bamboo tasks

Michael Rüegg edited this page May 16, 2017 · 10 revisions

The Bamboo plan DSL provides support for a lot of built-in Bamboo tasks like the "Source Code Checkout" task:

tasks {
    checkout() {
        description 'checkout repo'
        forceCleanBuild true

        repository(name: 'Bamboo Job DSL') {
            checkoutDirectory 'src'
        }
    }
}

But there exist hundreds of community-provided Bamboo tasks in the Atlassian Marketplace where the DSL does not provide special syntax for. This does not mean that these tasks cannot be used in the plug-in. The DSL offers a standard way to use and configure any task with the syntax custom. See the following example for the Sonar for Bamboo Maven Task:

tasks {
    custom(pluginKey: 'ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.maven3task') {
        description 'Analyze with SonarQube Maven'
        configure(
                chosenSonarConfigId: 1,
                useGradleWrapper: false,
                failBuildForSonarErrors: true,
                failBuildForBrokenQualityGates: false,
                executable: 'mvn3',
                illegalBranchCharsReplacement: '_',
                useNewGradleSonarQubePlugin: false,
                sonarJavaTarget: '1.8',
                sonarJavaSource: '1.8',
                environmentVariables: 'JAVA_OPTS="-Xms128m -Xmx1024m"',
                replaceSpecialBranchChars: false,
                buildJdk: 'JDK 1.5',
                additionalProperties: '-sonar.branch="master"',
                autoBranch: true,
                useGlobalSonarServerConfig: true,
                workingSubDirectory: 'src'
        )
    }
}

As you can see, there are default attributes (description and enabled) any task has and there is a configure block with the task-specific fields. You probably ask yourself how you can get the plug-in task key (ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.maven3task) and the field names (like sonarJavaSource). The way to retrieve these values is to add the Bamboo task you want to use to your build job, configure it as you would like to have it, and then save the configuration form while watching the POST request in your browser's dev tools. See the following example:

Task configuration form

The form data of the POST request contains the field values of the Bamboo task:

View of Chromes browser tools to watch the POST request

The task key is also part of the POST request and is named createTaskKey. With these instructions, you should be able to write the DSL for any custom tasks.

Clone this wiki locally