Hi Team,
I am trying to reduce reusable code within my project pipeline; however, I am facing issues while passing a variable to the pipeline.
definitions:
steps:
- step: &reusable-deploy-step
name: "deploy"
script:
- echo "Deploying in $Environment"
pipelines:
custom:
deploy-all-sandboxes:
parallel:
- step:
<<: *reusable-deploy-step
name: "deploy to Dev sandbox"
variables:
Environment: "Dev"
-step:
<<: *reusable-deploy-step
name: "Deploy to QA sandbox"
variables:
Environment: "QA"
I am encountering an issue where the YAML validates in Bitbucket validator passes successfully. However, when running the pipeline, the environment variable value appears empty.
Can someone provide any suggestions to resolve this?
Hi @Younusuddin Mohammad and welcome to the community!
There is a bug with the validator and when yaml anchors are used, the validator does't show errors. The reason that the variables in your builds are empty is that the keyword variables cannot be used this way in a custom pipeline, it can only be used in the way described in this doc.
What you can do is set up deployment environments in this repository, define variables in these environments, and then adjust your yml. You need to have admin permissions to the repo to set up deployment environments.
These are the steps to do this:
definitions:
steps:
- step: &reusable-deploy-step
name: "deploy"
script:
- echo "Deploying in $Environment"
pipelines:
custom:
deploy-all-sandboxes:
- parallel:
- step:
<<: *reusable-deploy-step
name: "Deploy to Dev sandbox"
deployment: Dev
- step:
<<: *reusable-deploy-step
name: "Deploy to QA sandbox"
deployment: QA
Please feel free to reach out if you have any questions!
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.