bitbucket-pipelines - 为 Bitbucket 自定义管道部署值使用变量
问题描述
我正在尝试使用传递给自定义管道的变量为步骤设置部署变量。这个想法是不必复制自定义管道,因为唯一的变化是从 bitbucket 设置中读取的部署变量。
定义如下,但抛出错误
pipelines:
custom:
my-pipeline:
- variables:
- name: deployment
- step:
deployment: $deployment
script:
- ...
我在这里遗漏了什么,还是部署密钥不允许接受变量?
解决方案
不幸的是,您不能在该deployment
字段中使用变量。变量仅在字段中可用script
。但是,您的问题可以通过另一种方式轻松解决:锚点
例如:
definitions:
steps:
- step: &Test-step
name: Run tests
script:
- npm install
- npm run test
- step: &Deploy-step
name: Deploy to staging
script:
- npm install
- npm run build
- fab deploy
pipelines:
default:
- step: *Test-step
- step:
<<: *Deploy-step
name: Deploy to Staging
deployment: staging
trigger: manual
custom:
Staging Deployment
- step: *Test-step
- step:
<<: *Deploy-step
deployment: staging
Production Deployment
- step: *Test-step
- step:
<<: *Deploy-step
deployment: production
推荐阅读
- javascript - 在 Enquirer CLI Prompt 中填写问题和答案字段
- c# - Firebase Unity:如何处理没有互联网连接的情况
- django - 在一个 Django 项目中拥有 DEV、TEST、PROD 环境的最佳方式
- javascript - 为什么导航栏不在 DOM 中呈现
- python - 泛型类型类的正确类型提示
- xml - 在 PowerShell 中,如何定义字符范围,包括 (dash -) 反斜杠 \ az、AZ、0-9?
- python - 本地主机在运行 Python/VS 代码时拒绝连接
- php - PHP 重新格式化 XML 所需的步骤
- javascript - 为什么给我未定义?
- azure - 远程客户端无法连接到在 Azure VM 中运行的 redisai docker 容器