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:
- 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.
- 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?