NOTE: this is not much of a question; but a suggestion/request for consideration of new functionality
I want to run some steps only in particular cases.
My expectation would be like:
definitions:
steps:
- step: &do-some-deployemnt
name: Do some Deployment
script:
- echo "this happens only if condition is met"
pipelines:
pull-requests:
'**':
- step:
script:
- echo "this happens only if condition is met"
when: <condition>
custom:
some-custom-pipeline-1:
- variables:
- name: VAR_NAME
- step:
<<: *do-some-deployemnt
deployment: Production
when: <condition>
some-custom-pipeline-2:
- variables:
- name: VAR_NAME
- step:
<<: *do-some-deployemnt
deployment: Test
when: <condition>
- step:
<<: *do-some-deployemnt
deployment: Production-1
when: <condition>
- step:
<<: *do-some-deployemnt
deployment: Production-2
when: <condition>
for the purpose of clarity, lets say in Bit-Bucket setting we created "deployment variables"
on here
- pull-requests uses git diff
- some-custom-pipeline-1 uses "custom variables"
- some-custom-pipeline-2 uses both "custom variables" and "deployment variables"
now, condition could be anything which evaluates to true/false at the end
when: $(git diff --name-only --diff-filter=AMDR HEAD^ some-directory-or-file) != ""
we have multiple steps, only deploy the one if a deployment variable matches the user input variable
when: ENVIRONMENT_NAME = VAR_NAME # if deployment variable matched custom variable
based on a custom variable input by the user. On example some-custom-pipeline-2, there is 1 test deployment and 2 different production deployments. User might want to deploy Test, or both Productions.
when: VAR_NAME = 'production' # if custom variable matched string
NOTE:
a similar question was asked at:
https://community.atlassian.com/t5/Bitbucket-Pipelines-questions/Defining-Conditional-Steps/qaq-p/1192816?tempId=eyJvaWRjX2NvbnNlbnRfbGFuZ3VhZ2VfdmVyc2lvbiI6IjIuMCIsIm9pZGNfY29uc2VudF9ncmFudGVkX2F0IjoxNTgzODY0ODE3NDU2fQ%3D%3D
but this question was routed ONLY to file changes