Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Pipelines Variables not exported when using YAML anchors

vlupia
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!
April 15, 2025

Hi,

I’m testing the new Output Variables feature, which should allow variables to be shared across subsequent steps.

The documentation example works fine:

pipelines:
default:
- step:
script:
- echo "VARIABLE_NAME=my-value" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- VARIABLE_NAME
- step:
script:
- echo $VARIABLE_NAME

I can see the variable being exported and available in the step’s Build Setup logs:

Pipeline variables:
    
VARIABLE_NAME: my-value

However, when I define output variables from steps that are referenced through YAML anchors, no variables are exported.

Example pipeline:

definitions:
steps:
- step: &default
name: Common Steps Configuration
size: 2x
runs-on:
- 'self.hosted'
- 'linux'

- step: &init
<<: *default
name: Initialize
script:
- echo "VARIABLE_NAME=my-value" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- VARIABLE_NAME

- step: &build
<<: *default
name: Build
script:
- echo $VARIABLE_NAME

pipelines:
default:
- step: *init
- step: *build

In this case, the second step does not print anything and the pipeline variable is not listed in the step's Build Setup logs.

Am I missing anything here?

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events