Dynamic Pipelines - How to define step/stage templates

Marcin Kielar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 10, 2024

Here's the use case: Let's say we have multiple repositories, each deploying a microservice. I'd like to give the Developers the possibility to simply write:

pipelines:
  default:
- deploy-to-environment:
environment: dev

And then make my Dynamic Pipeline replace deploy-to-environment entry with a stage that runs terraform plan, terraform apply, some post-deployment test, tagging commit with environment tag, and perhaps few other steps.

Issues:

  1. While I can replace existing step with some other step definition, the key in YAML must be "step", otherwise Bitbucket complains about wrong pipeline syntax. It seems like Bitbucket is performing Pipeline Validation before sending the body of the pipeline to Dynamic Pipeline App. So there seems to be no way to define a custom step template/id in my pipeline and get it replaced with something meaningful.
  2. I was considering doing that by applying conventions on step name, but then I have no way to pass additional parameters, so that Dynamic Pipeline App would know, e.g. to which environment I want to deploy.

The only solution I thought of so far, is to create a script entry, and then use some convention in there, like:

pipelines:
default:
- step:
script:
- |
replaceWithStage({
id: "deploy-to-environment"
parameters:
environment: dev
})

And then try to evaluate that within Dynamic Pipeline App. Not yet sure if that would work.

Other things I considered:

  • I've seen Shared Pipelines, but they come as a whole - one cannot just share a single stage or step definition.
  • I've seen Pipes, but they are public-only and act as step script, so they don't really remove any complexity or repetition.

 

 

Isn't there any other solution to simply reuse a definition of a stage, and be able to parameterize it?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events