Artifacts on gitlab

Wirtting this to see if someone can explain me how is it that artifacts work.
I have the yml file more a less like this (is a sample that I tried)

stages:

  • mi stage1
  • mi stage2

execute commands and save file:
image: gitlab.sample.com/box/dir1/image1
stage: mi stage1

script:
- touch /tmp/file1 #just create a simple file
- free >> /tmp/file1 #adding memory stats to it.
- df -h >> /tmp/file1 #adding disk info to same file.
- ls /tmp #

artifacts:
paths:
- /tmp/file1

login in and continue using artifact:
image: gitlab.sample.com/box/dir1/image1
stage: mi stage2
dependencies:
- execute commands and save file
script:
- echo “adding some new lines at the end of the file” >> /tmp/file1
- tail -2 /tmp/file1
- cat /tmp/file1

Here results of that STAGE1

Fetching changes…
HEAD is now at 27980d1 Update .gitlab-ci.yml
Checking out 27980d1d as Test1…
Skipping Git submodules setup
touch /tmp/archivo free >> /tmp/archivo
df -h >> /tmp/archivo ls /tmp
file1
Uploading artifacts…
WARNING: /tmp/archivo: no matching files

STAGE 2

Checking out 27980d1d as Test1…
Skipping Git submodules setup
Downloading artifacts for execute commands and save file (4991)…
Downloading artifacts from coordinator… ok id=4991 responseStatus=200 OK token=CyZgzvJy
echo "adding some new lines at the end of the file" >> /tmp/file1 tail -2 /tmp/file1
adding some new lines at the end of the script
$ cat /tmp/file1
adding some new lines at the end of the script
Job succeeded

Why Im having that warning on stage 1? I want to use artifact in nex stage and i can´t. I did a “ls” command as you can see and the file is there on tmp directory. Also I see that an artifactory was created at the end, but empty.

Can some one please explain how this works on gitlab? Artifacts, and how to use same artifact on nex stage ?

thanks!

1 Like