Forums

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

Is there any way to use different variable values in different pipeline steps?

Mike Burton June 11, 2019

We're using pipelines to run our test suite, and we have a bitbucket-pipelines.yml file like so:

 

image: java:8
clone:
depth: 1
definitions:
caches:
gradle: ~/.gradle
gradlewrapper: ~/.gradle/wrapper
runTaggedTests: &runTaggedTests
- step:
caches:
- gradle
- gradlewrapper
script:
- cd tests
- TESTHOST=$HOST.domain.com bash ./gradlew test -PincludeTags=$TAG
runAllTests: &runAllTests
- parallel:
- step: *runTaggedTests
variables:
TAG: testTag1
- step: *runTaggedTests
variables:
TAG: testTag2
pipelines
:
custom: # triggered manually or via schedule
test-env1:
- step: *runAllTests
variables:
HOST: test-env1
test-env2:
- step: *runAllTests
variables:
HOST: test-env1

However this pipeline fails because the step is defined as a list. I think I can do this using pipes, but I'm wondering if there's a simple way to fix the definitions above to work, as I'd rather fix this file (which is familiar to all of our devs) rather than introduce custom pipes (which are unfamiliar to all of our devs) if I can.

1 answer

0 votes
Mike Burton June 11, 2019 edited

Also tried this:

image: java:8
clone:
depth: 1
definitions:
caches:
gradle: ~/.gradle
gradlewrapper: ~/.gradle/wrapper
runTaggedTests: &runTaggedTests
- step:
caches:
- gradle
- gradlewrapper
script:
- cd tests
- TESTHOST=$HOST.domain.com bash ./gradlew test -PincludeTags=$TAG
runAllTests: &runAllTests
- parallel:
- step:
<<: *runTaggedTests
variables:
TAG: testTag1
- step:
<<: *runTaggedTests
variables:
TAG: testTag2
pipelines
:
custom: # triggered manually or via schedule
testenv1:
- step:
<<: *runAllTests
variables:
HOST: testenv1

but still no dice (this one fails with "There is an error in your bitbucket-pipelines.yml at [pipelines > custom > testenv1 > 0 > parallel > 0]. To be precise: The step section is empty or null.")

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events