3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CircleCIでjob間でフォルダを共有する

Posted at

はじめに

JavaScriptフレームワークを使用しているプロジェクトでbuild job→deploy jobという流れで
CircleCIを通して行なった際にbuild jobで生成されたフォルダがdeploy jobにないため、failedしていた。
今回はその対処方法のメモ

persist_to_workspace, attach_workspaceを使う

  • persist_to_workspace
    別ジョブでもbuildしたフォルダを使用できるようにしてくれる。

  • attach_workspace
    persist_to_workspaceで指定したフォルダを読み込む。

設定例

version: 2.1
orbs:
  node: circleci/node@3.0.0

jobs:
  build:
    docker:
      - image: 'circleci/node:14.3.0'
    working_directory: ~/dir
    steps:
      - checkout
      - run:
          name: npm install & build
          command: npm install && build command
      - persist_to_workspace:
          root: ~/dir
          paths:
              - build_folder

  deploy:
    docker:
      - image: ...
    working_directory: ~/dir
    steps:
      - checkout
      - attach_workspace:
          at: ~/dir
      - run:
          name: deploy
          command: deploy command
        
workflows:
  ...
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?