Welcome

YAML and JSON Variables Loader is a Bamboo plugin to load build and deployment variables from YAML and JSON files.  It is similar to the built in Inject Bamboo Variables task but supports files with either YAML or JSON properties.

Task Configuration

Configuration of the task simply requires specifying the path of your YAML or JSON file and selecting whether the extracted variables should be of Job or Result scope.

  • Job scoped variables have local scope and they cease to exist when the job finishes.
  • Result scoped variables persist beyond the execution of a Job and are passed into subsequent stages or related deployment releases.

Bamboo Variable Naming

The names of the variables follow these rules:

  • each nested map/dictionary entry is separated by a period, e.g. application.name
  • arrays are indexed using brackets, e.g. [0]

All variable names are prefixed with bamboo. based on how Bamboo variables function. See the Atlassian documentation on Bamboo variables for more details.

This scheme is most easy understood using examples.

YAML Example

YAML File
---
description: Application Configuration
applications:
- name: my-app
  routes:
  - route: example.com
  - route: www.example.com/foo
  - route: tcp-example.com:1234
  env:
    greeting: hello
    BUNDLE_WITHOUT: test:development
stuff: other

The variables that will be set are:

Bamboo Variables
bamboo.description=Application Configuration
bamboo.applications[0].name=my-app
bamboo.applications[0].routes[0].route=example.com
bamboo.applications[0].routes[1].route=www.example.com/foo
bamboo.applications[0].routes[2].route=tcp-example.com:1234
bamboo.applications[0].env.greeting=hello
bamboo.applications[0].env.BUNDLE_WITHOUT=test:development
bamboo.stuff=other


JSON Example

JSON File
{
  "applications": {
    "test-app": {
      "one": "value",
      "two": "value2"
    }
  },
  "services" : [
     "service1", "service2"
  ]
}

The variables that will be set are:

Bamboo Variables
bamboo.applications.test-app.one=value
bamboo.applications.test-app.two=value2
bamboo.services[0]=service1
bamboo.services[1]=service2

Debugging Tips

The built in Dump variables to log task is useful when trying to understand what variables have been loaded and what their keys are.

Issues

Create a new issue here.

key summary type created updated due assignee reporter priority status resolution
Loading...
Refresh

Development

The project can be found at https://bitbucket.org/dehringer/bamboo-yaml-variables-loader.