From here I learned that Bitbucket Pipeline supports ifs statements.
How do I do multi-line blocks inside if statements?
This doesn't compute:
script:
- if [ $BITBUCKET_BRANCH == "master" ];
then;
echo Line1
echo line2
fi;
Bitbucket pipelines are written in YAML, so you can take full advantage of the YAML language.
For multiline, you can also use either |
or >
operators.
- >
if [ $BITBUCKET_BRANCH == 'master' ]; then
echo "We are on master :)"
else
echo "We are not on master :("
fi
More information: https://yaml-multiline.info/
NB: I guess this use-case was just an example, but you can also filter pipelines steps by branches directly: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-SectionDescription
I found that this works:
- if [ $BITBUCKET_BRANCH == 'master' ]; then
- echo "We are on master"
- 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