1
1

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 5 years have passed since last update.

CircleCIで、直前に実行したJobによって次のJobで実行する処理を変える

Posted at

gitのリポジトリ直下に適当なディレクトリとファイルを追加する

異なるJob間で共有するディレクトリを作成

  • mkdir circleci

共有するファイルを作成

  • touch circleci/environment

直前に実行するJobの変数を格納

変数をenvironmentに格納後にpersist_to_workspaceを使って、異なるJob間で変更したファイルを共有

.circleci/config

    - run:
        name: Update Environment
        command: |
            cat <<'EOF' | tee -a ./circleci/environment
                export PATH=~/.local/bin:$PATH
                export ENV='staging'
                export REGION='eu-west-1'
            EOF
    - persist_to_workspace:
        root: circleci
        paths:
            - "./*"

次のJobで変数を読み込み

直前にpersist_to_workspaceで保存したディレクトリをattach_workspaceでアタッチする

.circleci/config
    - attach_workspace:
        at: circleci
    - run:
        name: Setting environment
        command: |
          source ./circleci/environment
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?