nz_*_*ree 6 javascript continuous-integration bitbucket node.js bitbucket-pipelines
我是 bitbucket 管道的新手,并尝试使用 javaScript 通过 bitbucket 管道部署我的代码。我的问题是我们可以声明变量(例如:var flag = false),然后根据标志值编写 if/else 语句吗?
下面是我的 pipelines.yml 文件
# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:12.18.2
pipelines:
branches: # deploying as per branches
feature/pocDepTerex: # poc master branch
- step:
caches:
- node
script:
- node -v
Run Code Online (Sandbox Code Playgroud)
在这里,我想声明一个标志并仅在该标志为 true 时运行脚本 node -v 。
请告诉我是否有任何方法可以在管道中做到这一点
dav*_*ing 17
你一定可以!虽然您可能习惯在bitbucket-pipelines.yml中编写一系列单行命令,但您可以使用标准 YAML 语法插入多行内容。例如:
image: node:12.18.2
pipelines:
branches: # deploying as per branches
feature/pocDepTerex: # poc master branch
- step:
caches:
- node
script:
- export MY_FLAG=true
- |
if [ "$MYFLAG" = true ]; then
node -v
fi
Run Code Online (Sandbox Code Playgroud)
全面披露:我在 Atlassian 工作,但不在 Bitbucket Pipelines 团队:)
Vis*_*M.R 12
当涉及的步骤是 shell 类型命令时,daveruninseverything 发布的答案工作得很好,但在使用 Bitbucket 管道时则没有帮助。(有关 Bitbucket 管道的更多信息,请点击此处)
可以在执行 Bitbucket 管道之前添加以下行,如下所示,以实现条件:
- if [ "$BITBUCKET_WORKSPACE" != test ]; then exit 0 ; fi
- pipe: atlassian/aws-s3-deploy:0.2.4
Run Code Online (Sandbox Code Playgroud)
上面添加的行确保pipe仅当工作区名称为 时才会执行test。
| 归档时间: |
|
| 查看次数: |
13844 次 |
| 最近记录: |