We have several stages consisting of one or more steps. We would like ability to define if a stage should be executed based on condition declared as workspace or repository variable.
Looked at the schema but condition does not let us use variables as intended. https://bitbucket.org/atlassianlabs/intellij-bitbucket-references-plugin/raw/master/src/main/resources/schemas/bitbucket-pipelines.schema.json
pipelines:
default:
- stage:
name: Deploy to QA
deployment: qa
condition: ${QA_STAGE_ENABLED} == "true"
trigger: manual
steps:
- step:
condition: ${QA_STAGE_ENABLED} == "true" is what is being recommended. At the moment the only way to skip a stage is to comment it out in bitbucket-pipelines.yaml file which is not the most pleasant experience.
Bitbucket Pipeline's
conditionclause only works forchangesetsthat too for justincludePathcondition as of now. If you want to use a variable or an artifact derived value to skip an step, you can implement a bash-styleIFcondition as the first step of yourscript, it will execute the step and mark it as done but you can skip any lines of code you do not want to execute as part of this step, for example: