How to access screen shots made in CI test on specific gitlab-runner

1.6k views Asked by At

I want to make screen shots of my app in CI tests using specific runner (its working on my pc, its not "shared-runner").

Its a basic docker runner. I tried to pass builds_dir to runner config with full path /home/myuser/mybuilds but after successful test, the folder is empty. (it seems its relative to build, not the linux path)

The screenshots are probably to be taken but paths seem to be relative.:

app.browserWindow.capturePage().then(function (imageBuffer) {
            fs.writeFile('/home/myuser/mybuilds/page-full-path.png', imageBuffer)
        })

So how to access build folder after the build in docker?

EDIT
I could use artifacts like this:

app.browserWindow.capturePage().then(function (imageBuffer) {
    console.log("This test path");
    console.log(path.join(__dirname));
    var mypath = path.join(__dirname, '../..', 'testimgages', "test.png");
    fs.writeFile(mypath, imageBuffer)
})   

and then in gitlab-ci.yml

mytest
  script:
  - mytests
  artifacts:
    paths:
    -testimages

and then download images from gitlab.com but is there a way to make it faster or local viewing without going to gitlab.com?

2

There are 2 answers

2
odk On BEST ANSWER

If it's on your server then you can just add something like: -v /some/local/path:/data/screenshots:rw to your docker run command. It will bind mount local dir on your server to /data/screenshots in container. Then all you save there will appear in local dir.

0
Krzysztof Atłasik On

If you don't want to add volume you could copy files using docker cp:

docker cp <containerId>:/data/screenshots /local/path

You can find your container id with docker ps.