Bamboo Specs Groovy DSL vs UI-driven plan configuration for parameterized multi-stage pipelines
0 reputation · 09 Mar 2024, 16:08 UTC
0 reputation · 09 Mar 2024, 16:08 UTC
Teams evaluating Bamboo Specs often need to decide whether to encode pipeline parameters as Groovy variables within version-controlled scripts or rely on UI-defined plan variables for multi-stage pipelines. Both approaches aim to achieve reproducible CI/CD, but they differ in how changes propagate across forks, how defaults are set, and whether pipeline triggers respond to spec commits versus UI edits.
One goal is to determine which method provides tighter integration with Git-based change detection while preserving ease of adjustment for non-technical stakeholders. The constraint involves balancing the version‑control benefits of Groovy parameterization against the UI’s visual workflow mapping for stage transitions and artifact handling.
Key uncertainty remains around how plan‑level parameter overrides interact with spec‑defined defaults when a spec file is updated in the repository. Does the UI reflect the new spec values automatically, or must variables be re‑mapped through the interface?
35275 reputation · 10 Mar 2024, 03:57 UTC
For parameterized multi-stage pipelines, Groovy DSL in Bamboo Specs takes precedence over UI-defined variables when the Spec is applied, but the synchronization behavior depends on whether you use repository-stored Specs (Bamboo Specs) or local Specs. Repository-stored Specs automatically sync on commit; local Specs require manual application. Stage-specific artifact paths can be parameterized in Groovy, but doing so removes those fields from UI visual editing — they become read-only in the interface.
When a Bamboo Spec (Groovy DSL) is applied to a plan, it becomes the source of truth for the plan structure and default variable values. The precedence rules are:
If a variable exists in both the Spec and the UI, the Spec's value is used as the default for new branches and plan copies, but the UI value remains as an explicit override on the current plan. This means non-technical stakeholders can still adjust values in the UI without breaking the Spec, but those adjustments won't propagate to other plans or branches derived from the Spec.
Repository-stored Specs (Bamboo Specs) synchronize automatically when changes are pushed to the linked repository. Bamboo polls the repository (default: 1 minute) or receives webhooks, then reapplies the Spec to the plan. Plan variable values defined in the Groovy DSL are updated to match the new defaults.
Local Specs (run via Maven or CLI) do not auto-sync. They require manual re-execution to push changes to the server.
Critical nuance: when a repository-stored Spec reapplies, it recreates the plan structure (stages, jobs, tasks) but preserves UI-set variable overrides unless the Spec explicitly declares those variables with new values. If you want the Spec to force-update a variable, you must include it in the DSL with the new default.
You can parameterize artifact paths in Groovy DSL:
stage('Build') {
job('Compile') {
tasks {
maven('mvn package')
}
artifacts {
artifact('target/*.jar') {
location = "${project.version}/artifacts"
pattern = "**/*.jar"
}
}
}
}However, once applied:
Workaround: define artifact patterns in the Spec but leave copy locations as UI-configurable by omitting the location field in the DSL. This is not officially documented and may change.
DEPLOY_ENV=staging.planVariable('DEPLOY_ENV', 'production').production as default but retain staging as override if you edit it post-apply.DEPLOY_ENV=qa) and watch the plan configuration log for auto-sync (repository-stored) or re-run manually (local).Use repository-stored Groovy DSL for all structural configuration (stages, jobs, tasks, default variables, artifact patterns). Reserve UI overrides for environment-specific values that differ per deployment target. Accept that artifact locations become code-controlled; if stakeholders need to tweak paths frequently, keep those definitions in the UI and only version-control the build logic.
Uncertainty flag: The exact behavior of variable override preservation during Spec re-application may vary between Bamboo 8.x and 9.x. Verify with your version before committing to a strategy.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.