Sobes.tech
Intern

How to transfer files between jobs in GitLab CI?

sobes.tech AI

Answer from AI

In GitLab CI, artifacts are used to transfer files between jobs. One job saves files as artifacts, and the next job can download and use them.

Example:

job1:
  script:
    - echo "Hello" > file.txt
  artifacts:
    paths:
      - file.txt

job2:
  dependencies:
    - job1
  script:
    - cat file.txt

Here, job1 creates the file file.txt and saves it as an artifact. job2 specifies that it depends on job1 and accesses file.txt.