GitLab.com artifact browse works as expected, download only has folders (no files)

I am trying to collect files from my repo, on tag pushed, into a single zip. However, the closest I can get results in different output shown in the GitLab.com UI “Browse” button view vs what I get from the “Download” button.

.gitlab-ci.yaml

image: alpine:latest

stages:
  - publish

publish:
  stage: publish
  only:
    - tags
  script:
    - ./prep-gitlab-publish.sh
  artifacts:
    name: ProjectName-$CI_COMMIT_TAG
    paths:
      - ./Publish

prep-gitlab-publish.sh

mkdir -p ./Publish/Docs && cp ./docs/ProjectName-GettingStarted.pdf ./Publish/Docs/ProjectName-GettingStarted.pdf
mkdir -p ./Publish/EnvFiles
mkdir -p ./Publish/PgAdmin && cp -r PgAdmin ./Publish
mkdir -p ./Publish/ReverseProxy && cp -r ReverseProxy ./Publish
mkdir -p ./Publish/Volumes/localdb
cp util-script.ps1 ./Publish
cp stack-base.yaml ./Publish
cp start-script.ps1 ./Publish

However, this seemed to produce clobbered results (folders/files copied over each other).

I thought perhaps it was a problem with the shebang missing from the script, and added…

#!/bin/sh

…which I verified is in the alpine:latest image. But, this resulted in a “sh not found” error message in the job log.

If I write the script with explicit path info and destination file names…

mkdir -p ./Publish/Docs && cp ./docs/ProjectName-GettingStarted.pdf ./Publish/Docs/ProjectName-GettingStarted.pdf
mkdir -p ./Publish/EnvFiles
mkdir -p ./Publish/PgAdmin && cp -r ./PgAdmin/servers.json ./Publish/PgAdmin/servers.json
mkdir -p ./Publish/ReverseProxy && cp -r ./ReverseProxy/projectname.conf ./Publish/ReverseProxy/projectname.conf
mkdir -p ./Publish/Volumes/localdb
cp ./util-script.ps1 ./Publish/util-script.ps1
cp ./stack-base.yaml ./Publish/stack-base.yaml
cp ./start-script.ps1 ./Publish/start-script.ps1

I see in the job output…

Uploading artifacts...
./Publish: found 13 matching files and directories 

…which is the correct number of objects. Then if I click the “Browse” button in the GitLab.com UI under “Job artifacts”, I see the expected results (folders and files as specified in the script)! However, if I click “Download”, I get the zip file with the expected name, and the directories are present, but no files!

How is it possible that I can “browse” the results, but the download file has something different?

After searching, I did come across this unanswered post which seems possibly similar (in effect, not on specific technologies used).

If I include untracked: true in the yaml (thinking that the target output folder and its contents are not tracked in git), and download the artifact zip, I get a zip file with two Publish folders, neither of which have the correct contents.

Thinking there was perhaps some conflict going on with the stage name I am using and the artifact path (does GitLab create a folder for the stage?) I included at the top of my script rm -rf ./Publish… to no positive effect. The job log doesn’t seem to indicate the auto creation of a conflicting path/folder name.

What am I possibly missing? It seems almost impossible that this is a bug and I am the first to stumble across it?


PS: I tried changing the output folder to Published (and including untracked) …

{...snipped...}

Uploading artifacts...
./Published: found 13 matching files and directories
untracked: found 6 files

{...snipped...}

…and now there is just a single Published folder in the root of the zip, but it too has just the folders (no files) despite “Browse” showing all the contents as expected.

The found 13... looks correct, but I am not sure what untracked is finding. My understanding is that untracked should not be necessary since I am wanting to include everything in the artifacts:paths path (“Publish”/“Published”).


PPS: I saw in another post a user included a ls -la to get a file listing in the job output. This returned…

No such file or directory

…I am somewhat at a loss as to how that could be!


PPPS: Changing the .gitlab-ci.yaml’s, script: property to…

publish:
  stage: publish
  only:
    - tags
  script:
    - mkdir -p $CI_PROJECT_DIR/Published
    - ls -la $CI_PROJECT_DIR

…resulted in the log showing all the expected files in the git repo as expected (which I am trying to arrange in ./Published.

If I don’t include the mkdir command, there is no conflicting Publish or Published folders (still unsure how untracked: true resulted in two folders of the same name in the zip artifact).

The difference between the auto-populated folders, and the mkdir ./Published folder is that the Published folder isn’t writable by anyone other than root. I don’t imagine this would create a problem for the artifact zip?

drwxrwxrwx    2 root     root          4096 Nov 24 02:52 PgAdmin
drwxr-xr-x    2 root     root          4096 Nov 24 02:52 Published   <-----
drwxrwxrwx    2 root     root          4096 Nov 24 02:52 ReverseProxy

It doesn’t error when collecting/copying the folders and files (so it must be able to find and copy them), they just simply aren’t there in the downloaded zip.

Rather than using a separate .sh script file (as shown in other examples) including the same commands in the yaml’s script list, eg: …

image: alpine:latest

stages:
  - publish

publish:
  stage: publish
  only:
    - tags
  script:
    - mkdir -p ./Published/EnvFiles
    - mkdir -p ./Published/Docs && cp ./docs/TopHandOnsite-GettingStarted.pdf ./Published/Docs/TopHandOnsite-GettingStarted.pdf
    - mkdir -p ./Published/PgAdmin && cp -r ./PgAdmin ./Published/
    {...snipped...}

…works as expected! The same/expected contents shown in “Browse” are also all in the resulting file via “Download”.

This doesn’t seem correct, but unblocks me. I suspect it is a shell/context issue.