我是CircleCI工作流程的新手,我想创建一个包含两个步骤的工作流程。
version: 2
jobs:
build:
docker:
- image: docker.repo.ch/image:${TAG}
CircleCI工作流程中是否存在某种机制来将值作为参数从一项构建工作移交给另一项?
答案 0 :(得分:4)
由于每个运行步骤都是一个新的shell,因此环境变量是 没有跨步骤共享。如果您需要一个环境变量 只需一步即可访问,请使用BASH_ENV导出值。
https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-step
workflows:
version: 2
pass_tag:
jobs:
- create_tag
- use_tag:
requires:
- create_tag
executors:
node:
docker:
- image: circleci/node:4.8.2
jobs:
create_tag:
executor: node
steps:
- run: echo "export MY_TAG=$CIRCLE_SHA1" >> $BASH_ENV
use_tag:
executor: node
steps:
- run: echo $MY_TAG
使用CircleCI orbs
(如库)来构建并推送图像:
version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@6.7.0
workflows:
version: 2
example:
jobs:
- aws-ecr/build-and-push-image:
account-url: DEV_AWS_ECR_ACCOUNT_URL
aws-access-key-id: DEV_ACCESS_KEY_ID
aws-secret-access-key: DEV_SECRET_ACCESS_KEY
create-repo: true
repo: '${CIRCLE_PROJECT_REPONAME}'
region: AWS_DEFAULT_REGION
tag: '${CIRCLE_SHA1}'
- pull_image:
requires:
- aws-ecr/build-and-push-image
jobs:
pull_image:
*** pull and use your image here ***