Save artifacts from service image

I have a custom-made docker image for GitLab CI services that runs an X server and saves the entire session to a video file. The idea is simply to aid in debugging a flaky CI process that requires X. I’m trying to find a nice way to get the resulting video file from the service container into the job’s artifacts. Documentation about services doesn’t seem to cover this aspect; does anyone know of a way to pull it off?

Thanks for your help!

I figured it out. The documentation mentions:

Shared /builds directory

Services can access files from the build because all services have the job directory mounted as a volume under /builds.

It calls them “shared” and says all services have them, but it wasn’t really clear what this was. Turns out it’s shared with the job as well. I can put the video in there and the job can save it as an artifact, as long as the service waits for the job to actually check the project out there (do it too soon and the checkout process wipes it). Good enough!

I’ve proposed an update to the docs to be a little more clear about this.

1 Like

Amazing work, @kyrofa! In particular, thank you for the docs update MR. :bowing_man:

1 Like

It’s still unclear (to me) what the mapping means.

For example, if I use the postgres service, then where is the postgresql/data (or equivalent) directory mapped to the “parent” container? I looked up the entire container (find / -type d) at the end of the job, I couldn’t find it anywhere. The job did have some commands that updated the postgres database which ran successfully, so I can be sure the postgres service was setup correctly.

@dragondive I may not be understanding your issue, but only that /builds directory is shared. I doubt the postgres service stores its data in there, so your job won’t have direct access to it. You can always dump the database from the job, though.