I've been fighting with bitbucket pipelines for a while now.
I need to perform a step that requires deployment level variables, but is not a deployment
I know about Deployments, and I know that I can only have a single deployment step. I'm ok with that because the deployment is linked back to the Jira ticket and I do want to know when something has actually been deployment successfully and to which environment.
BUT
Take Terraform for example. Before deploying infrastructure, I want to see what it's going to change before applying it for real, so i must factor in a manual trigger.
For this I have a -plan step, which is environment specific. I don't want to make that a deployment because it's not actually deploying, yet how else can I get the variables??
- step: &plan
image: hashicorp/terraform
name: Validate and Plan
script:
- cd src
- terraform init -backend-config="bucket=$BACKEND_BUCKET" -backend-config="key=$BITBUCKET_DEPLOYMENT_ENVIRONMENT/terraform.tfstate" -upgrade
- terraform validate
- terraform plan
On Azure DevOPs this is simple. Bitbucket just needs to separate the deployment variables and defining what is an actual deployment step.
So my question to bitbucket is: how can I achieve this? I can't pass an argument. Do I have to output a var to a file each time?