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

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
AUG Leaders

Atlassian Community Events