Resolving Issues With Bitbucket Shared Pipeline and Environment Variables
Resolving Issues With Bitbucket Shared Pipeline and Environment Variables
Bitbucket has several frustrating limitations around shared pipelines, especially when environment variables are involved.
The Atlassian documentation explicitly calls out one of them:
Note: There is a known limitation with using variables in custom pipelines that utilize a shared Pipeline Configuration. If a repository imports a shared Pipeline Configuration and uses it as part of a custom pipeline, variable values specified at runtime via the UI will not pass to the pipeline execution. Instead, the default values specified in the exported Pipeline configuration will be used.
Source: https://support.atlassian.com/bitbucket-cloud/docs/share-pipelines-configurations/
If you need to use runtime input variables with a shared pipeline, there are two main options.
1. Capture user input first, then call a child pipeline
| |
This approach works for passing user-provided values forward, but it comes with a major drawback: you completely lose access to Bitbucket Deployments features, including environment-scoped variables.
Source: https://support.atlassian.com/bitbucket-cloud/docs/child-pipeline-step-options/
2. Trigger the shared pipeline through the API and pass the required variables
| |
This second approach is usually more practical if you need both shared pipeline logic and deployment-specific variables. The tradeoff is that it is more complex because you must trigger the pipeline indirectly through the Bitbucket API.
