CircleCI:作业同时运行时使用哪个工作区?

时间:2019-03-21 02:00:07

标签: circleci circleci-2.0 circleci-workflows

我有以下简化的.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

基本上,工作流程顺序是:

  1. install-dependencies
  2. build-stagingbuild-production在安装依赖项之后并发运行。我假设attach_workspaceinstall-dependencies作业中获取数据。我说得对吗?
  3. deploy-stagingbuild-staging之后运行。 deploy-productionbuild-production之后运行。我不确定运行attach_workspace时会附加什么工作区。

如您所见,多个作业可以同时运行。但是,我的问题是,当不清楚某个任务以什么顺序完成时,persist_to_workspaceattach_workspace的工作方式令人困惑。与缓存不同,似乎无法命名我想要的数据。

例如,假设作业按以下顺序完成:

  1. install-dependencies
  2. build-staging
  3. build-production
  4. deploy-staging
  5. deploy-production

在第3步和第4步中得到什么工作区?是它之前的工作区(在这种情况下,将是第2步和第3步)?还是基于父任务(即第1步)? / p>

0 个答案:

没有答案