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
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:
but this question was routed ONLY to file changes
As far as I know steps can not have conditions (e.g. the when in your question, like the when in Ansible probably).
But steps can have a script and within a script you can encode all sort of conditional expressions. So maybe moving the condition into the step could do it in your case already?
this would be a before script then, which I think should not be necessary as you could do it at the very beginning of the script and exit 0 otherwise. that should work.
a feature request for a when would merely result in a different expression language, not the shell expressions you have as examples in your question.
but I'm not from Atlassian, so just what pops into my limited mind. Someone from Atlassian will also tell you in an answer how/where you can file feature requests.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the difference being
if a step runs, and at the start of the script you implement your conditional, the step still runs. The initial "Build setup" takes place, consumes resources, and shows the step as run.. even if with an exit as it's first command
If the conditional is run before, then if false, the step does not even run. On the case of example some-custom-pipeline-2, either 1 or 2 steps would run, but not all 3. And with some extra logic, if no steps are run in a pipeline, then the entire pipeline might not even run.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And what would be your understanding where the when condition would be executed?
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.