Examples for AddTask Action

Examples for AddTask Action

On this page

The addTask action can be used to add arbitrary tasks to a job. However, you must know the parameter fields that each task uses and needs. Normally, the task provider doesn't document this. The following gives some examples. If the task you want is not one of the examples, the parameters can be discovered: see How to determine fields for addTask. If you get errors, you will need to debug the field problem by using the url used by the CLI tool in a browser so the errors are more prevalent. Run the action with --verbose and look for url that is being used and failing. This is the best that can be done until Bamboo provides proper REST APIs to help with this scenario.

Description

Details

Common

Some common fields are handled with specific CLI parameters

CLI Field

POST Field

Discussion

plan

planKey

The POST field value is a 3 part name including job. CLI uses 2 separate fields for this.

job


3rd part of planKey POST field

taskKey

createTaskKey

Required for add. We have defined some common aliases (case insensitive):

  • ANT

  • CHECKOUT

  • CLI_BAMBOO

  • CLI_CONFLUENCE

  • CLI_CRUCIBLE

  • CLI_FISHEYE

  • CLI_HIPCHAT

  • CLI_JIRA

  • CLI_BITBUCKET

  • CLI_UPM

  • CLI_SERVICE_DESK

  • COMMAND

  • GANT

  • GINT

  • GRADLE

  • GRADLEW

  • GROOVY

  • MAVEN2

  • MAVEN3

  • SCP

  • SQL

  • SCRIPT

  • SSH

description

userDescription


disable

taskDisabled=true


Source checkout

POST Field

Example POST Value

Discussion

createTaskKey

com.atlassian.bamboo.plugins.vcs%3Atask.vcs.checkout

  • Task keys are in the form xxx:yyy. Use : in place of %3A.

  • taskKey: com.atlassian.bamboo.plugins.vcs:task.vcs.checkout

  • alias: CHECKOUT

selectedRepository_0

defaultRepository

Says to use the default repository for the plan. Default (not specifying the parameters) should just use the default as well.

For other repositories, you will need the repository id either explicitly or from Variable replacement using @repositoryId@.

  • The variable in a script after an addRepository or getRepository action

cleanCheckout

true

Defaults to false.

checkoutDir_0


You must set it to blank or a specific value (otherwise you will get an NullPointerException).

Using the default repository

-a addTask --plan XX-XX --job JOB1 --taskKey CHECKOUT --description "get source" --disable --field1 selectedRepository_0 --value1 defaultRepository --field2 cleanCheckout --value2 true --field3 checkoutDir_0 --value3 ""

Using another respository in a script

-a addRepository         --plan @plan@ --repository my-repository
-a addTask               --plan @plan@ --job @job@ --taskKey CHECKOUT --fields selectedRepository_0:@repositoryId@,checkoutDir_0:,cleanCheckout:true

Script

POST Field

Example POST Value

Discussion

createTaskKey

com.atlassian.bamboo.plugins.scripttask%3Atask.builder.script

  • Task keys are in the form xxx:yyy. Use : in place of %3A.

  • taskKey: com.atlassian.bamboo.plugins.scripttask:task.builder.script

  • alias: SCRIPT

scriptLocation

INLINE

INLINE or FILE.

scriptBody

exit -1

Body for INLINE scripts. Use " \n " for new lines (leading and trailing blanks are significant.

script

myscript.sh 

File for FILE scripts.

argument


Command line arguments. Defaults to blank.

environmentVariables


Environment variables. Defaults to blank.

workingSubDirectory


Working subdirectory. Defaults to blank.

runWithPowershell

true

Defaults to false.

-a addTask --plan XX-XX --job JOB1 --taskKey SCRIPT --field1 scriptLocation --value1 INLINE --field2 scriptBody --value2 "exit -1"

Maven

POST Field

Example POST Value

Discussion

createTaskKey

com.atlassian.bamboo.plugins.maven%3Atask.builder.mvn2

com.atlassian.bamboo.plugins.maven%3Atask.builder.mvn3

  • Task keys are in the form xxx:yyy. Use : in place of %3A. 

  • taskKeys: 

    • com.atlassian.bamboo.plugins.maven:task.builder.mvn2

    • com.atlassian.bamboo.plugins.maven:task.builder.mvn3

  • aliases: MAVEN2, MAVEN3

label

Maven 2

Executable label of type Maven 2.

buildJdk

JDK

Build JDK.

environmentVariables


Environment variables. Defaults to blank.

workingSubDirectory


Working subdirectory. Defaults to blank.

testChecked

true

Defaults to false.

testDirectoryOption

standardTestDirectory

Defaults to standardTestDirectory. Alternate is customTestDirectory. Must be set if testChecked is true.

testResultsDirectory


Defaults to **/target/surefire-reports/*.xml.

projectFile


Defaults to blank.

-a addTask --plan XX-XX --job JOB1 --description "Simple" --taskKey MAVEN2 --field1 label --value1 "Maven 2" --field2 goal --value2 "compile" --field3 buildJdk --value3 JDK

Groovy

Gradle

Gradle Wrapper

Gant

POST Field

Example POST Value

Discussion

createTaskKey

org.swift.bamboo.groovy%3Agroovy

  • Task keys are in the form xxx:yyy. Use : in place of %3A. 

  • taskKeys:

    • org.swift.bamboo.groovy:groovy

    • org.swift.bamboo.groovy:gradle

    • org.swift.bamboo.groovy:gradlew

    • org.swift.bamboo.groovy:gant

  • aliases: GROOVY, GRADLE, GRADLEW, GANT

label

Groovy

Executable label like Groovy, Gradle, Gradle Wrapper, or Gant.

scriptLocation

FILE

INLINE or FILE.

script

my-script.groovy

Script location for FILE.

scriptBody


INLINE script. Use " \n " for new lines (leading and trailing blanks are significant.

buildJdk

JDK

Build JDK.

environmentVariables


Environment variables. Defaults to blank

workingSubDirectory


Working subdirectory. Defaults to blank.

testChecked

true

Defaults to false.

testDirectoryOption

standardTestDirectory

Defaults to standardTestDirectory. Alternate is customTestDirectory.
Must be set if testChecked is true.

testResultsDirectory


Defaults to **/*reports/*.xml for Groovy and **/*reports/*.xml,**/*results/*.xml for Gradle

-a addTask --plan XX-XX --job JOB1 --description "Simple" --taskKey GROOVY --field1 label --value1 "Groovy" --field2 scriptLocation --value2 FILE --field3 script --value3 my-script.groovy --field4 buildJdk --value4 JDK

GINT

POST Field

Example POST Value

Discussion

createTaskKey

org.swift.bamboo.groovy%3Agint

  • Task keys are in the form xxx:yyy. Use : in place of %3A.

  • taskKey: org.swift.bamboo.groovy:gint

  • alias: GINT

label

Gant

Executable label referencing a Gant executable.

scriptLocation

FILE

INLINE or FILE.

script

integration-test.gant

Script location for FILE.

scriptBody


INLINE script. Use " \n " for new lines (leading and trailing blanks are significant.

targets


Specific testcases (targets) to run. Defaults to blank.

levelAll

true

Include all integer levels. Equivalent to command line -Dlevel=all. Defaults to false.

includeLevelsAll

true

Include all named levels. Equivalent to command line -DincludeLevels=all. Defaults to false.

clean

true

Ignore previous run state, run tearDown and setUp. Equivalent to command line -Dclean. Defaults to false.

verbose

true

Log additional information. Equivalent to command line -Dverbose. Defaults to false.

stopOnFail


Stop running more testcases once a testcase fails. Equivalent to command line -DstopOnFail. Defaults to false.

propertyLocation

FILE

INLINE or FILE.

propertyFile


Property location for FILE.

propertyBody


INLINE script.

buildJdk

JDK

Build JDK.

environmentVariables


Environment variables. Defaults to blank.

workingSubDirectory


Working subdirectory. Defaults to blank.

testChecked

true

Defaults to false.

testDirectoryOption

standardTestDirectory

Defaults to standardTestDirectory. Alternate is customTestDirectory.

testResultsDirectory


Defaults to **/*reports/*.xml.

-a addTask --plan XX-XX --job JOB1 --description "Integration test" --taskKey GINT --field1 label --value1 "Gant" --field2 scriptLocation --value2 FILE --field3 script --value3 integration-test.gant --field4 buildJdk --value4 JDK --fields levelAll:true,includeLevelsAll:true,clean:true,verbose:true,stopOnFail:false,testChecked:true

CLI

POST Field

Example POST Value

Discussion

createTaskKey

org.swift.bamboo.acli%3Ajira

  • Task keys are in the form xxx:yyy. Use : in place of %3A. 

  • taskKeys: 

    • org.swift.bamboo.acli:jira

    • org.swift.bamboo.acli:confluence

    • org.swift.bamboo.acli:bamboo

    • org.swift.bamboo.acli:stash

    • org.swift.bamboo.acli:hipchat

    • org.swift.bamboo.acli:crucible

    • org.swift.bamboo.acli:fisheye

  • alias: CLI_JIRA, CLI_CONFLUENCE, CLI_BAMBOO, CLI_STASH, CLI_HIPCHAT, CLI_CRUCIBLE, CLI_FISHEYE

scriptLocation

FILE

INLINE or FILE.

script

create-jira-issue.txt

Script location for FILE.

scriptBody

--action ...

INLINE script. Use " \n " for new lines (leading and trailing blanks are significant.

-a addTask --plan @plan@ --job @job@ --description "Create JIRA issue" --taskKey org.swift.bamboo.acli:jira --field1 scriptLocation --value1 FILE --field2 script --value2 "create-jira-issue.txt"

Docker run

POST FieldExample POST ValueDiscussion
createTaskKeycom.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli 
commandOptionrun
imageregistry.address:port/namespace/repository:tag
dockerfileOptioninline
-a addTask --plan @plan@ --job @job@ --description "Run a container" --taskKey com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli --field1 commandOption --value1 run --field2 image --value2 registry.address:port/namespace/repository:tag --field3 dockerfileOption --value3 inline

Docker build

POST FieldExample POST ValueDiscussion
createTaskKeycom.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli 
commandOptionbuild
repositoryregistry.address:port/namespace/repository:tag
dockerfileOptionexisting
-a addTask --plan @plan@ --job @job@ --description "Build Docker image" --taskKey com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli --field1 commandOption --value1 build --field2 repository --value2 registry.address:port/namespace/repository:tag --field3 dockerfileOption --value3 existing

Docker push

POST FieldExample POST ValueDiscussion
createTaskKeycom.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli 
commandOptionpush
repositoryOptioncustom
dockerfileOptioninline
pushRepository

registry.address:port/namespace/repository:tag


-a addTask --plan @plan@ --job @job@ --description "Push image" --taskKey com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli --field1 commandOption --value1 push --field2 dockerfileOption --value2 inline --field3 registryOption --value3 custom --field4 pushRepository --value4 registry.address:port/namespace/repository:tag

Artifact download

POST FieldExample POST ValueDiscussion
createTaskKey

com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:artifactdownloadertask

  • Alias since 5.2: ARTIFACT_DOWNLOAD

sourcePlanKeyX
artifactId_1-1

First artifact id, use -1 to download all shared artifacts.

 Must be the numeric id (sad) .

localPath_1
First directory path relative to the working directory. Blank is valid. 
artifactId_212345Second artifact id.
localPath_2targetSecond directory path.
etc...

-a addTask --plan @plan@ --job @job@ --description "Get artifacts" --taskKey ARTIFACT_DOWNLOAD --field1 sourcePlanKey --value1 XXX-PLAN1  --field2 artifactId_1 --value2 -1 --field3 localPath_1 --value ""

NPM

POST FieldExample POST ValueDiscussion
createTaskKey

com.atlassian.bamboo.plugins.bamboo-nodejs-plugin:task.builder.npm


runtimeNode.js
commandinstall


-a addTask --plan @plan@ --job @job@ --description "NPM install" --taskKey com.atlassian.bamboo.plugins.bamboo-nodejs-plugin:task.builder.npm --field1 runtime --value1 Node.js  --field2 command --value2 install

SQL

POST FieldExample POST ValueDiscussion
createTaskKey

com.appfire.bamboo.sql:sql

Required for add. Alias: SQL (since 5.5)
scriptLocation

FILE

INLINE or FILE.
script
update-tracking-database.sql
Script location for FILE.
scriptBody
INLINE script.
dbProfiledbUrl = jdbc:postgresql://examplegear.com:5432/test dbUser = automation | dbPassword = automationRequired.
outputFormatRAW_WITH_LINE_BREAKS

Optional. Defaults to RAW_WITH_LINE_BREAKS. Values: RAW, RAW_WITH_LINE_BREAKS, WIKI, HTML

outputFile
Optional. Path to file for result output
-a addTask --plan @plan@ --job @job@ --description "Database update" --taskKey SQL --field1 script --value1 update-tracking-database.sql --field2 dbProfile --value2 "dbUrl = jdbc:postgresql://examplegear.com:5432/test dbUser = automation | dbPassword = automation"

SSH

POST FieldExample POST ValueDiscussion
createTaskKey

com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask

Required for add. Alias: SSH
host

examplegear.com.

Required.
username
root
Required.
authTypeKEY SSH key reference. Others: PASSWORD
password

change_keytrueRequired when updating SSH key.
commandsome-command

Command to run on remote system.

-a addTask --plan @plan@ --job @job@ --description "Run remote command" --taskKey SSH --field1 host --value1 ${bamboo.host} --field2 username --value2 root --field3 authType --value3 KEY --field4 private_key --value4 @file --field5 change_key --value5 true --field6 command --value6 some-command --file ssh-key-file.txt

Your task not listed yet?

Contribute your validated configuration by asking and answering your own question!