I have the following simplified .circle/config.yml
file:
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
Basically the workflow ordering is:
install-dependencies
-
build-staging
&build-production
is run concurrently after install-dependencies. I assumeattach_workspace
gets the data frominstall-dependencies
job. Am I correct? -
deploy-staging
is run afterbuild-staging
.deploy-production
is run afterbuild-production
. I am not sure what work-space is attached when runningattach_workspace
.
As you can see, multiple jobs can run concurrently. However, my issue is that I am confused as to how persist_to_workspace
and attach_workspace
works when it is not clear in what order a certain task finishes. Unlike caching, it does not seem to be possible to name what data I want.
For example, lets say the jobs finish in the following order:
install-dependencies
build-staging
build-production
deploy-staging
deploy-production
What workspace do I get at step 3 and step 4. Is it always the one preceding it (in this case it would be step 2 & 3), or is it based on the parent task (i.e. step 1)?