I've been trying out triggered pipelines (using the `triggers` section, as opposed to traditional selectors under `pipelines`). For simple custom pipelines it's working great, but I'd now like to invoke a custom pipeline with variables. Consider this sort of custom pipeline:
check-environment:
- variables:
- name: env
default: dev
allowed-values:
- dev
- test
- prod
- step:
- script: # ...
triggers:
pullrequest-push:
- condition: *anyChange
pipelines:
- check-environment
triggers:
pullrequest-push:
- condition: *anyChange
pipelines:
- pipeline:
name: check-environment
variables:
- env: test
I have come up with a workaround that I'll call "deparameterisation". Using child pipeline input variables, you can hard code parameters into parent pipelines:
check-environment:
- variables:
- name: env
default: dev
allowed-values:
- dev
- test
- prod
- step:
script: # ...
check-environment-dev:
steps:
- step:
name: Run `check-environemnt` against dev
type: pipeline
custom: check-environment
input-variables:
env: dev
check-environment-test:
steps:
- step:
name: Run `check-environemnt` against test
type: pipeline
custom: check-environment
input-variables:
env: test
It is reasonably horrendous, creating a plethora of nearly-meaningless custom pipelines, but at least the script is DRY. Until the `triggers` section supports pipelines as something more than plain strings, I think this will have to do :(
Hi @Paul Hicks ,
If I understood it correctly, what you are trying to do is not supported since custom pipelines can only be triggered manually.
Depending on what you are trying to do a dynamic pipelines could also help.
Our Bitbucket app, Flowie supports this kind of pattern via the smart pipelines plugin. You can trigger the custom pipeline and provide different variables based on any of the conditions, including target branch and labels.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The documentation you linked to is apparently out of date (by a few years, I think).
Custom pipelines can be triggered manually, via shared configuration (pipeline: import), schedules, and (as I'm doing here) new-style triggers. The custom pipeline part isn't the problem: that's all working fine. The problem is invoking custom pipelines from new-style triggers: only the custom pipeline name can be provided in the `pipelines` array. The array is typed to strings, only. There is no way to pass in variables.
See below links for definitions on how to use custom pipelines in these other ways.
https://support.atlassian.com/bitbucket-cloud/docs/pipeline-triggers/
https://support.atlassian.com/bitbucket-cloud/docs/share-pipelines-configurations/
https://support.atlassian.com/bitbucket-cloud/docs/pipeline-start-conditions/#Trigger-type
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see what you mean now - thanks for clarifying it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.