0
0

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.

CirclrCIのキャッシュのkeyに環境変数を使う

Posted at

CircleCIでrebuildするとき、キャッシュなしで実行する「rebuild without cache」機能があるんですが、workflowを使った場合その機能が使えません(ボタンが表示されません)。

cacheのkeyに環境変数を使うことで似たような機能を実現します。

対応

CircleCIで、Settings > Environment Variables で環境変数(今回はCACHE_KEY)を設定して、

image.png

こんな感じでkeyに利用します。

.circleci/config.yml
- restore_cache:
    keys:
      - gem-cache-{{ .Environment.CACHE_KEY }}-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
      - gem-cache-{{ .Environment.CACHE_KEY }}-{{ arch }}-{{ .Branch }}
      - gem-cache-{{ .Environment.CACHE_KEY }}

環境変数を別の値に書き換えてrebuildすればkeyが異なるのでキャッシュなしで実行できます。

以上です :hugging:

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?