将参数发送到 yml 锚点以获取 bitbucket 中的一个步骤-pipelines.yml
Send argument to yml anchor for a step in bitbucket-pipelines.yml
我想在使用 bitbucket 管道调用锚点时发送参数
这是我正在使用的文件,我必须调用 after-script
因为我需要推送到某个 S3 存储桶
definitions:
steps:
- step: &node-build
name: Build React app
image: node:lts-alpine
script:
- npm install --no-optional
- npm run build
artifacts:
- build/**
- step: &aws-ecr-s3
name: AWS S3 deployment
image: amazon/aws-cli
script:
- aws configure set aws_access_key_id "${AWS_KEY}"
- aws configure set aws_secret_access_key "${AWS_SECRET}"
pipelines:
branches:
master:
- step: *node-build
- step:
<<: *aws-ecr-s3
after-script:
- aws s3 cp ./build s3://my-app-site-dev --recursive
staging:
- step: *node-build
- step:
<<: *aws-ecr-s3
after-script:
- aws s3 cp ./build s3://my-app-site-uat --recursive
我正在尝试执行类似以下的操作,以便不必使用 after-script
部分
definitions:
steps:
- step: &node-build
name: Build React app
image: node:lts-alpine
script:
- npm install --no-optional
- npm run build
artifacts:
- build/**
- step: &aws-ecr-s3 $FIRST-ARGUMENT
name: AWS S3 deployment
image: amazon/aws-cli
script:
- aws configure set aws_access_key_id "${AWS_KEY}"
- aws configure set aws_secret_access_key "${AWS_SECRET}"
- aws s3 cp ./build s3://${FIRST-ARGUMENT} --recursive
pipelines:
branches:
master:
- step: *node-build
- step: *aws-ecr-s3 my-app-site-dev
staging:
- step: *node-build
- step: *aws-ecr-s3 my-app-site-uat
据我所知,您只能覆盖 YAML 锚点的特定值。尝试 'pass arguments' 无效。
相反,Bitbucket Pipelines 提供 Deployments - 一种 ad-hoc 方法,可以根据环境为变量分配不同的值。您需要创建两个部署(例如 dev
和 uat
),并在引用步骤时使用它们:
pipelines:
branches:
master:
- step: *node-build
<<: *pushImage
deployment: uat
staging:
- step: *node-build
<<: *pushImage
deployment: dev
有关 Bitbucket 部署的更多信息:
https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Deployment-variables
https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-monitor-deployments/
我想在使用 bitbucket 管道调用锚点时发送参数
这是我正在使用的文件,我必须调用 after-script
因为我需要推送到某个 S3 存储桶
definitions:
steps:
- step: &node-build
name: Build React app
image: node:lts-alpine
script:
- npm install --no-optional
- npm run build
artifacts:
- build/**
- step: &aws-ecr-s3
name: AWS S3 deployment
image: amazon/aws-cli
script:
- aws configure set aws_access_key_id "${AWS_KEY}"
- aws configure set aws_secret_access_key "${AWS_SECRET}"
pipelines:
branches:
master:
- step: *node-build
- step:
<<: *aws-ecr-s3
after-script:
- aws s3 cp ./build s3://my-app-site-dev --recursive
staging:
- step: *node-build
- step:
<<: *aws-ecr-s3
after-script:
- aws s3 cp ./build s3://my-app-site-uat --recursive
我正在尝试执行类似以下的操作,以便不必使用 after-script
部分
definitions:
steps:
- step: &node-build
name: Build React app
image: node:lts-alpine
script:
- npm install --no-optional
- npm run build
artifacts:
- build/**
- step: &aws-ecr-s3 $FIRST-ARGUMENT
name: AWS S3 deployment
image: amazon/aws-cli
script:
- aws configure set aws_access_key_id "${AWS_KEY}"
- aws configure set aws_secret_access_key "${AWS_SECRET}"
- aws s3 cp ./build s3://${FIRST-ARGUMENT} --recursive
pipelines:
branches:
master:
- step: *node-build
- step: *aws-ecr-s3 my-app-site-dev
staging:
- step: *node-build
- step: *aws-ecr-s3 my-app-site-uat
据我所知,您只能覆盖 YAML 锚点的特定值。尝试 'pass arguments' 无效。
相反,Bitbucket Pipelines 提供 Deployments - 一种 ad-hoc 方法,可以根据环境为变量分配不同的值。您需要创建两个部署(例如 dev
和 uat
),并在引用步骤时使用它们:
pipelines:
branches:
master:
- step: *node-build
<<: *pushImage
deployment: uat
staging:
- step: *node-build
<<: *pushImage
deployment: dev
有关 Bitbucket 部署的更多信息:
https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Deployment-variables https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-monitor-deployments/