LoginSignup
3
0

More than 1 year has passed since last update.

GitLab CI/CDでビルド後の成果物を違うステージで再利用する方法

Posted at

ユースケース

例えば、stage1でビルドを行い、その実行ファイルをstage2で単体テストなど行うユースケースで便利です。

GitLab Runnerの生成物に対するデフォルトの挙動

GitLab Runnerのデフォルトでは、stage1での生成物は、stage2に遷移するタイミングで消されるため、stage2でパスを指定してもFile Not Foundエラーが出ます。これは、常に環境をクリーンに保つという設計上の方針だとは思いますが、初心者にはつまづきやすいです。

対処

生成物(=artifacts)をdependenciesを用いて明示的に引き継ぐ旨を.gitlab-ci.ymlにぶち込みましょう

前のステージ(.gitlab-ci.yml)
stage1:
  artifacts:
    untracked: true
次のステージ(.gitlab-ci.yml)
stage2:
  dependencies: 
    - build-job

参考文献

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