summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/syntax_templates/Artifacts example.gitlab-ci.yml
blob: 7182b96594d198dab8277fbe777c07f02719cc9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# You can use artifacts to pass data to jobs in later stages.
# For more information, see https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html
#

stages:
  - build
  - test
  - deploy

build-job:
  stage: build
  script:
    - echo "This job might build an important file, and pass it to later jobs."
    - echo "This is the content of the important file" > important-file.txt
  artifacts:
    paths:
      - important-file.txt

test-job-with-artifacts:
  stage: test
  script:
    - echo "This job uses the artifact from the job in the earlier stage."
    - cat important-file.txt
    - echo "It creates another file, and adds it to the artifacts."
    - echo "This is a second important file" > important-file2.txt
  artifacts:
    paths:
      - important-file2.txt

test-job-with-no-artifacts:
  stage: test
  dependencies: [] # Use to skip downloading any artifacts
  script:
    - echo "This job does not get the artifacts from other jobs."
    - cat important-file.txt || exit 0

deploy-job-with-all-artifacts:
  stage: deploy
  script:
    - echo "By default, jobs download all available artifacts."
    - cat important-file.txt
    - cat important-file2.txt

deploy-job-with-1-artifact:
  stage: deploy
  dependencies:
    - build-job # Download artifacts from only this job
  script:
    - echo "You can configure a job to download artifacts from only certain jobs."
    - cat important-file.txt
    - cat important-file2.txt || exit 0