A few things here:
$BITBUCKET_PIPELINES_VARIABLES_PATH
is overwritten with a single value (ENV=dev
, ENV=qa
, or ENV=preprod
) each time. There is no risk of appending multiple values, which could cause errors.YAML A uses shared configurations like <<: *check-java-images
and <<: *check-completed
. While this is valid YAML syntax, ensure that the anchors (*check-java-images
, *check-completed
, etc.) are properly defined elsewhere in the pipeline.
The output-variables
section is used to define variables that can be passed to subsequent steps. However, if a step that relies on ENV
runs before the Set ENV
step completes, the variable will be undefined. Ensure that steps depending on ENV
are executed after the step that sets it.
Fixed example (sorry about the formatting):
definitions:
steps:
- step: &check-java-images
script:
- echo "Checking Java images for $ENV environment"
- step: &check-ui-image
script:
- echo "Checking UI images for $ENV environment"
- step: &check-completed
script:
- echo "Check completed for $ENV environment"
pipelines:
branches:
main:
# Check image's CommitIDs against Dev
- step:
name: Set Dev environment
script:
- echo ENV=dev > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
name: Check Java images commitID against dev env
- step:
<<: *check-ui-image
name: Check UI image commitID against dev env
- step:
<<: *check-completed
name: Check completed on dev
deployment: dev
# Check image's CommitIDs against QA
- step:
name: Set QA environment
script:
- echo ENV=qa > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
name: Check Java images commitID against QA env
- step:
<<: *check-ui-image
name: Check UI image commitID against QA env
- step:
<<: *check-completed
name: Check completed on QA
deployment: qa
# Check image's CommitIDs against Preprod
- step:
name: Set Preprod environment
script:
- echo ENV=preprod > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
name: Check Java images commitID against preprod env
- step:
<<: *check-ui-image
name: Check UI image commitID against preprod env
- step:
<<: *check-completed
name: Check completed on preprod
deployment: preprod
If this still fails, please raise a ticket with support - as we need to look at your build environment/YAML config:
Cheers!
- Ben (Bitbucket Cloud Support)
Thanks Ben, thanks for your help!
Answering in order to your points....
- Not sure I understand this first point.... is `>` the right way to go in my case? I think so, as `>>` (if I remember correctly) fails on the second invocation
- Yes, good point, I didn't add the syntax of the shared step definitions, but yes, they're there (if not, the pipeline would have probably failed differently). Thanks for checking!
- Yes, that is already the case: ENV is used after being defined in the step with `output-variables`; I've compared the "working-logic" with the "broken-logic" for a while already, but maybe I'm missing something obvious.
I'll do another couple of experiments, but after that I'll probably reach out to support.
Thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
- Correct, > (single arrow) is the right way to go - I should have made this clearer :)
If you are unable to reach out to support for whatever reason - please let me know your timezone and I'll raise a ticket on your behalf.
Cheers!
- Ben (Bitbucket Cloud Support)
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.