【发布时间】:2019-01-21 07:42:58
【问题描述】:
From here我了解到 Bitbucket Pipeline 支持 ifs 语句。
如何在 if 语句中做多行块?
这不计算:
script:
- if [ $BITBUCKET_BRANCH == "master" ];
then;
echo Line1
echo line2
fi;
【问题讨论】:
From here我了解到 Bitbucket Pipeline 支持 ifs 语句。
如何在 if 语句中做多行块?
这不计算:
script:
- if [ $BITBUCKET_BRANCH == "master" ];
then;
echo Line1
echo line2
fi;
【问题讨论】:
我发现这行得通:
- if [ $BITBUCKET_BRANCH == 'master' ]; then
- echo "We are on master"
- fi
【讨论】:
Bitbucket 管道是用 YAML 编写的,因此您可以充分利用 YAML 语言。
对于多行,您还可以使用| 或> 运算符。
- >
if [ $BITBUCKET_BRANCH == 'master' ]; then
echo "We are on master :)"
else
echo "We are not on master :("
fi
更多信息: https://yaml-multiline.info/
注意:我猜这个用例只是一个示例,但您也可以直接按分支过滤管道步骤: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-SectionDescription
【讨论】: