0

On a Linux system I am running a simple test job from the command line using the following command:

gitlab-runner exec docker --builds-dir /home/project/buildsdir test_job 

with the following job definition in .gitlab-ci.yml:

test_job:
  image: python:3.8-buster
  script:
    - date > time.dat 

However, the build folder is empty. after having run the job. I only can imaging that build-dir means a location inside the docker image.

Also after having run the job successfully I am doing

docker image ls

and I do not see a recent image.

So how can I "share"/"mount" the actual build folder for the docker gitlab job to the hosts system so I can access all the output files?

I looked at the documentation and I found nothing, the same for

gitlab-runner  exec docker --help 

I also tried to use artifcats

test_job:
  image: python:3.8-buster
  script:
    - pwd
    - date > time.dat 
  artifacts:
    paths:
      - time.dat

but that also did not help. I was not able to find the file time.dat anywhere after the completion of the job.

I also tried to use docker-volumes:

gitlab-runner exec docker --docker-volumes /home/project/buildsdir/:/builds/project-0 test_job
gitlab-runner exec docker --docker-volumes /builds/project-0:/home/project/buildsdir/ test_job

but neither worked (job failed in both cases).

Alex
  • 41,580
  • 88
  • 260
  • 469
  • My initial thought is I don't think this is possible since each build gets a newly created volume, which I believe will take precedence over any previously defined volumes if the paths conflict. Your best bet to keep files available after a build is to use `artifacts:`. Also keep in mind `gitlab-runner exec` [doesn't implement](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2797) all the functionality of the runner, including artifacts. – sytech Mar 22 '22 at 07:49
  • Yes sure, I can just "print out" the stuff I want to analyze later (to debug failing automated selenium tests), and then "copy-and-paste" from the terminal to a file. Yes sure... – Alex Mar 22 '22 at 07:57

1 Answers1

0

you have to configure your config.toml file located at /etc/gitlab-runner/

here's the doc: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section

first add a build_dir and mention it in the volumes at the end bind it with a directory on your host machine like this:

build_dir = "(Your build dir)"
[runners.docker]
   volumes = ["/tmp/build-dir:/(build_dir):rw"]
Hani Bikdeli
  • 23
  • 1
  • 7