I have a Bitbucket custom pipeline that consists of multiple steps. The deployment steps and pipeline logic are the same for multiple test tenants; only the tenant-specific configuration differs.
My requirement is to configure two deployment environments, for example:
tenant1tenant2I want to store tenant-specific values such as Azure client ID, client secret, tenant ID, subscription ID, etc. as Deployment Variables for each environment.
At the same time, I have some common/shared values that should remain as Repository Variables.
The desired flow is:
tenant1 or tenant2).For example:
Custom Test Pipeline
|
|-- Select Tenant
| |
| +-- tenant1
| | └── Tenant 1 Deployment Variables
| |
| +-- tenant2
| └── Tenant 2 Deployment Variables
|
+-- Same pipeline steps
|
+-- Shared values → Repository Variables
+-- Tenant values → Deployment VariablesIs there a supported way in Bitbucket Pipelines to dynamically select a Deployment environment based on a custom pipeline variable, so that the selected environment's Deployment Variables are automatically made available to all steps?
For example, something conceptually like:
pipelines:
custom:
deploy-test:
- variables:
- name: TENANT
allowed-values:
- tenant1
- tenant2
- step:
deployment: $TENANT
script:
- ./deploy.shI understand that deployment: may need to be statically defined in the YAML. If dynamic selection is not supported, what would be the recommended Bitbucket approach for this use case while avoiding duplication of the actual deployment steps?
I would particularly like to keep the secrets in Deployment Variables rather than Repository Variables, since they are tenant-specific.