Details
-
Suggestion
-
Resolution: Unresolved
-
None
Description
Right now, the only way (at least that I know of) to define step specific variables is to use deployments, but sometimes it might be useful to define variables for non-deployment steps as well. Defining some environment variables inside bitbucket-pipelines.yml for any step would be really useful for writing re-usable steps when using YAML anchors.
In our use case, we have a monorepo that contains frontend code, backend code, iac code etc. and we use build flags to build multiple applications from the same source code and deploy each of them to separate cloud environments, all from the same branch. Because there's no easy way to re-use our step definitions, there's a lot of duplication in the pipelines configuration that could be easily reduced if we could pass env variables to steps.
Here's a simplified example and a suggestion for syntax:
image: atlassian/default-image:2 definitions: steps: - step: &build name: build script: - ./install - ./lint - ./test - ./build $BUILD_TARGET pipelines: default: - step: name: Build (target 1) env: - BUILD_TARGET: 'build-target-1' <<: *build - step: name: Build (target 2) env: - BUILD_TARGET: 'build-target-2' <<: *build