I'm trying to upload files from a container as artifacts in my gitlab pipeline. I'm trying to create a shared volume. But I must be doing something wrong because I'm getting an error that there are no files to upload.
I have the following logic in my gitlab-ci.yml file:
variables:
SHARED_PATH: testresults
DOCKER_DRIVER: overlay2
deployDev:
stage: deployDev
environment:
name: development
script:
- docker volume create ${SHARED_PATH}
- docker build --platform linux/amd64 --target deployFunctionApp -t azuredeployserver .
- docker run -v ${SHARED_PATH}:/builds/TestResults azuredeployserver
artifacts:
when: always
paths:
- ${SHARED_PATH}/test-results.xml
reports:
junit:
- ${SHARED_PATH}/test-results.xml
except:
- main
when: manual
tags:
- mac-pipelines
This is the error:
$ docker run -v ${SHARED_PATH}:/builds/TestResults azuredeployserver
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Uploading artifacts for successful job
00:00
Uploading artifacts...
WARNING: testresults/test-results.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: testresults/test-results.xml: no matching files
ERROR: No files to upload
Cleaning up project directory and file based variables
00:00
Job succeeded
Manual Attempt
after the image is built by the pipeline, i tried to do this manually from a commandline:
PS /Users/me/> docker run --rm -i -v=testresults:/build/testresults azuredeployserver ls -lah /build/testresults
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested total 12K drwxr-xr-x 2 root root 4.0K Apr 25 19:43 . drwxr-xr-x 3 root root 4.0K Apr 26 12:47 .. -rw-r--r-- 1 root root 809 Apr 25 19:42 test-results.xml
So I can see that the XML file is there - I just don't know how to get at it via gitlab-ci.yml
Any help would be appreciated.
EDIT 1
I've modified the script to try the docker cp command:
script:
- docker volume create ${SHARED_PATH}
- docker build --platform linux/amd64 --target deployFunctionApp -t azuredeployserver .
- docker run --name $DOCKER_IMAGE_BUILD_TAG_ID -v ${SHARED_PATH}:/builds/TestResults azuredeployserver
- docker cp $DOCKER_IMAGE_BUILD_TAG_ID:/builds/TestResults/*.xml ./TestResults/*.xml
But the error I see is
$ docker run --name $DOCKER_IMAGE_BUILD_TAG_ID -v ${SHARED_PATH}:/builds/TestResults azuredeployserver
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
Uploading artifacts for failed job
00:00
Uploading artifacts...
WARNING: .TestResults/test-results.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: .TestResults/test-results.xml: no matching files
ERROR: No files to upload
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 125
For now going to see if I can hardcode the name of the image to test the docker cp command. But if you see where I've gone astray, I'm all ears. Also, I guess if I'm using docker cp i can get rid of everything related to creating a volume?
SHARED_PATH=testresults docker volume create ${SHARED_PATH}
creates a docker volume named testreults
.
When you reference ${SHARED_PATH}/test-results.xml
in the artifacts section, you are saying, "Look for testresults/test-results.xml
in the GitLab Runner's local filesystem, which doesn't exist.
I think the most straightforward option here is to copy the file out of the container to a place where the GitLab Runner can access it.