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?
Hi @vlupia
Welcome to the community.
I'd just like to inform you that I'm currently verifying this interanally.
I'll update you once I get more information.
Regards,
Mark C
Hi @vlupia
Apologies for the late response here.
What I found out is that the feature should work with YAML anchors.
I've also tested the same YAML configurations on my end but I was able to get the correct variable of "my-value".
I'm currently running on Linux Docker version "3.23.0".
Could you confirm if you're using the updated runners version?
If not, could you try updating it by running the command below?
docker pull docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner
Let me know how it goes.
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great, glad to know it works now.
Feel free to accept the answer when you can.
Regards,
Mark C
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.