How to provide task configuration from an external source like a file

You want to provide task configuration for one or more fields from an external source like a file:

Step-by-step guide

This can be achieved by means of the file:// protocol as of Tasks for AWS 2.14:

  1. Add the steps/tasks to provide the content as a file, e.g. by downloading a shared artifact, checking it out from a source code repository or fetching the content from an URL with a script (the example uses the cloudformation.parameters.json Bitbucket snippet).

  2. Reference the file URL as the only content from a subsequent task's input field, e.g. file://${bamboo.build.working.directory}/cloudformation.parameters.json.

Workaround for Tasks for AWS < 2.14.0

For previous versions, this can be partially worked around by injecting the field configuration as a Bamboo variable instead, which can currently be achieved via these apps:

  • Variable tasks for Bamboo [source code | issue tracker] – this is one of the many apps by Atlassian Labs, and while formally unsupported, it is usually updated in a timely fashion regarding Bamboo API changes, if any
    Other than the API compatibility, the claimed version compatibility in the Atlassian Marketplace is frequently trailing by a minor version, which usually doesn't impact its functionality though (but might in case of API).

  • Variable Extractor Tasks for Bamboo [source code | issue tracker] – this is the only app by illucIT Software, yet it seems very well maintained and timely updated regarding Bamboo version and API changes

  • YAML and JSON Variables Loader [source code | issue tracker] – this a fairly new app by David Ehringer is fairly new, but David is developing and maintaining quite some high quality OSS apps and is well known for timely updates regarding Bamboo API changes, if any
    Similar to Atlassian Labs, David's claimed app version compatibility in the Atlassian Marketplace is sometimes trailing by a minor version, which usually doesn't impact its functionality though (but might in case of API changes).

The following steps are based on the Variable tasks for Bamboo app:

  1. Add the steps/tasks to provide the content as a file, e.g. by downloading a shared artifact, checking it out from a source code repository or fetching the content from an URL with a script (the example uses the cloudformation.parameters.json Bitbucket snippet).

  2. Install the Variable tasks for Bamboo app.

  3. Add a Variable File reader task to Get the full content of a file and inject it in a variable.



    1. Specify a variable name, e.g. cloudformation.parameters.
      Bamboo adds the prefix bamboo, so this variable needs to be referenced as ${bamboo.cloudformation.parameters}.

    2. Specify the file provided in step 1. to read the content from.
      Local scope is sufficient for reusing the variable inside the same job. Read the inline help for details on Result or Plan/Deployment scoped variables.

  4. Reference the variable as the only content from a subsequent task's input field, e.g. ${bamboo.cloudformation.parameters}.

 

Limitation

 This workaround has the limitation that the included content cannot use Bamboo variables in turn, because Bamboo doesn't yet support nested/recursive expansion of variables
(see ).