I am using bitbucket pipelines to deploy my code. I have multiple environments. I want to do different jobs depending on the environment (dev, test, pre-prod, prod). I want to know if there is if-else conditional ways to help me reduce duplicate code and reduce code.
If your pipeline includes only default, it will execute in all envs.
You can include keywords in your pipeline to deal with that. In execution order, will be something like:
image: node:9.8.0
pipelines:
branches:
#here, i'm saying to execute the step below only on branchs
develop:
#Here, when branch 'develop'
- step:
script:
master:
#Here, when branch 'master'
- step:
name: Buid Prod
script:
[....]
You can define other keywords to tell bitbucket when execute the steps, see more here, at docs
it can be done by the below sample
- if []; then
- #task
- elif []; then
- #task
- else
- #task
- fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With