我有以下简化的.circle/config.yml
文件:
version: 2
jobs:
install-dependencies:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
- persist_to_workspace:
root: ./
paths:
- ./
# Build jobs
build-staging:
docker:
- image: circleci/node:10.15.3
steps:
- attach_workspace:
at: ./
- run: yarn run build:staging
- persist_to_workspace:
root: ./
paths:
- dist
build-production:
docker:
- image: circleci/node:10.15.3
steps:
- attach_workspace:
at: ./
- run: yarn run build:prod
- persist_to_workspace:
root: ./
paths:
- dist
# deploy jobs
deploy-staging:
docker:
- image: circleci/python:3.7.2
steps:
- attach_workspace:
at: ./
- run: some-deploy-command
deploy-production:
docker:
- image: circleci/python:3.7.2
steps:
- attach_workspace:
at: ./
- run: some-deploy-command
workflows:
version: 2
build:
jobs:
- install-dependencies
# build
- build-staging:
requires:
- install-dependencies
- build-production:
requires:
- install-dependencies
# deploy
- deploy-staging:
requires:
- build-staging
- deploy-production:
requires:
- build-production
基本上,工作流程顺序是:
install-dependencies
build-staging
和build-production
在安装依赖项之后并发运行。我假设attach_workspace
从install-dependencies
作业中获取数据。我说得对吗?deploy-staging
在build-staging
之后运行。 deploy-production
在build-production
之后运行。我不确定运行attach_workspace
时会附加什么工作区。如您所见,多个作业可以同时运行。但是,我的问题是,当不清楚某个任务以什么顺序完成时,persist_to_workspace
和attach_workspace
的工作方式令人困惑。与缓存不同,似乎无法命名我想要的数据。
例如,假设作业按以下顺序完成:
install-dependencies
build-staging
build-production
deploy-staging
deploy-production
在第3步和第4步中得到什么工作区?是它之前的工作区(在这种情况下,将是第2步和第3步)?还是基于父任务(即第1步)? / p>