With bamboo-specs yaml is it possible to have a base deployment and merge yaml maps?

Jay Barra
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 4, 2022

I have multiple environments I deploy a project to where the only difference in the deployment are the variables associated and the triggers.

How can I specify a base deployment job and use the merge keys feature in the yaml-specs reader together?

What I want to achieve would be this.

---
version: 2
deployment:
name: Multi-env deployment
source-plan: MY-PROJ
release-naming:
version-name: release-1
environments:
- ENV-A
- ENV-B
- ENV-C

BASE: &deploy
tasks:
- clean
- script
interpreter: SHELL
scripts:
- echo ${bamboo_ENV_SPECIFIC}
variables: &base-variables
foo: bar
fiz: baz

ENV-A:
<<: *deploy
variables:
<<: *base-variables
ENV_SPECIFIC: A

ENV-B:
<<: *deploy
variables:
<<: *base-variables
ENV_SPECIFIC: B

ENV-C:
<<: *deploy
variables:
<<: *base-variables
ENV_SPECIFIC: C

But I get validation errors saying that BASE is an unused variable. Is my only option to move BASE into ENV-A?

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 4, 2022

Hello @Jay Barra Welcome to Atlassian Community!

Bamboo will expect all declared variables to be used. That's part of the YAML optimisation.

Considering "ENV-A" is your "template" environment. You can use the following to achieve the same results:

---
version: 2

deployment:
  name: Multi-env deployment
  source-plan: DEF-DEF

release-naming:
  next-version-name: release-1

environments:
  - ENV-A
  - ENV-B
  - ENV-C

ENV-A:
  tasks: &base-tasks
  - clean
  - script:
      interpreter: SHELL
      scripts:
      - echo ${bamboo_ENV_SPECIFIC}
      description: test
  variables: &base-variables
    ENV_SPECIFIC: A
    foo: bar
    fiz: baz

ENV-B:
  tasks: *base-tasks
  variables:
    <<: *base-variables
    ENV_SPECIFIC: B

ENV-C:
  tasks: *base-tasks
  variables:
    <<: *base-variables
    ENV_SPECIFIC: C


Kind Regards,

Eduardo Alvarenga
Atlassian SupporT APAC

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events