Hello,
Im trying to setup a base plan via yaml specs which should be used to create actual plans via includes. So I have created several files which are included in a test plan like this:
---
version: 2
plan:
project-key: SOMEPROJECT
key: SPECTEST
name: Test Plan
description: deploy to target
notifications: !include 'base-notifications.yaml'
repositories: !include 'base-repositories.yaml'
<SNIP>
Im trying to do the same for the plan variables that all plans that are going to use this as base should include, but the actual plans should also be able to add some additional vars or overwrite existing ones.
The file named base-variables.yaml has an example content like this:
somevar: somevalue
anothervar: anothervalue
I have tried a lot of different ways to achieve this but it seems that its not possible to do something like this:
variables: !include 'base-variables.yaml'
<<: { additional-var, additional-value }
This results in the below error:
27-Sep-2022 07:22:46 Bamboo YAML import failed: Invalid format of the YAML file: while parsing a block mapping 27-Sep-2022 07:22:46 in 'reader', line 2, column 1: 27-Sep-2022 07:22:46 version: 2 27-Sep-2022 07:22:46 ^ 27-Sep-2022 07:22:46 expected <block end>, but found '<block mapping start>' 27-Sep-2022 07:22:46 in 'reader', line 10, column 3: 27-Sep-2022 07:22:46 <<: { additional-var: additional-value } 27-Sep-2022 07:22:46 ^ 27-Sep-2022 07:22:46
Also tried something like this:
base-variables: &basevars !include 'base-variables.yaml'
plan-specific-vars: &planvars
somekey: somevalue
variables:
<<: *basevars
<<: *planvars
But that caused an issue because the properties base-variables and plan-specific-vars are not actually used.
How can I achieve the described outcome without having to list all variables in all plans?
Hello @margo
Welcome to Atlassian Community!
Nested includes are not available in Bamboo. They are tracked by the following feature request:
Make sure to vote and to follow that Feature Request so you can be notified when it moves forward.
As a workaround, you can use Anchors and Aliases to avoid duplicated code.
ENV-A: &defaults
tasks: &tasks
- clean
- script:
interpreter: SHELL
scripts:
- echo ${bamboo_ENV_SPECIFIC}
- echo this is Repo1
description: test
variables: &vars
foo: bar
fiz: baz
# Uses the same subset from ENV-A (defaults) and declares
# extra variables and overwrites others
ENV-B:
<<: *defaults
variables:
<<: *vars
foo: yeah
CUSTOM_VAR_1: abc123
GOOD: bye
HeLLo: World
Sincerely,
Eduardo Alvarenga
Atlassian Support APAC
--please don't forget to Accept the answer if the reply is helpful--
The problem with that workaround is that I do not have a deployment project, its just a build project, so there are no environments.
As mentioned in my original question I already tried several different approaches to use anchors with includes but none of them was working.
Any idea how to get this done when variables has to be on the first level of the yaml document, not nested in an environment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Eduardo Alvarenga any idea how to achieve the above mentioned case when the variables property has to be on the first level of the yaml document and is not nested in an environment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @margo
Unfortunately Bamboo will not support nested includes and base-level include assignments at this stage. These are documented on the following Feature requests:
We encourage you to add yourself as a watcher to be kept informed as to the state of the feature request moving forward and also vote on it.
There are a number of factors that determine how Atlassian prioritizes the Implementation of new features.
Kind regards,
Eduardo Alvarenga
Atlassian Support APAC
--please don't forget to Accept the answer if the reply is helpful--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.