Cannot use $CI_PROJECT_DIR in artifact path

Summary

Users who upgrade their GitLab runners to version 15.8.0 cannot use the $CI_PROJECT_DIR predefined variable in their job artifacts path and will get an error in the following form:

Uploading artifacts...
WARNING: ../<project_dir>: no matching files. Ensure that the artifact path is relative to the working directory (/builds/<user>/<project_dir>) 
ERROR: No files to upload 

It looks like this might have been introduced by the following recent MRs:

Steps to reproduce

  1. Setup GitLab instance on version 15.7.5.
  2. Install a GitLab runner on version 15.8.0.
  3. Create a repository and run the following CI/CD job.
.gitlab-ci.yml
stages:
  - build

build:
  stage: build
  script: touch test.txt
  artifacts:
    paths:
     - $CI_PROJECT_DIR
  1. Run a CI/CD pipeline and observe the error generated.

Actual behavior

User encounters the following error in the job.

Uploading artifacts...
WARNING: ../<project_dir>: no matching files. Ensure that the artifact path is relative to the working directory (/builds/<user>/<project_dir>) 
ERROR: No files to upload 

Expected behavior

The job should still succeed. Previously this will result to the following:

Uploading artifacts...
/builds/<user>/<project_dir>: found X matching files and directories 
WARNING: Part of .git directory is on the list of files to archive 
WARNING: This may introduce unexpected problems

Relevant logs and/or screenshots

job log
Running with gitlab-runner 15.8.0 (12335144)
  on runner-instance-1 NMXfKJW6, system ID: s_3249dd10573f
Resolving secrets
00:00
Preparing the "docker" executor
00:05
Using Docker executor with image ruby:2.7 ...
Pulling docker image ruby:2.7 ...
Using docker image sha256:c4825e3ad0feedc9c2c39d218e408249514f4409d2e7c91702587931a0450477 for ruby:2.7 with digest ruby@sha256:5a81b132459c16a2b5d6b2741099de7c6209c545cbfd8539e3c501eb13cd5ca5 ...
Preparing environment
00:01
Running on runner-nmxfkjw6-project-89-concurrent-0 via runner-instance-1...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/clsb_user_02/zd365279_artifact_path/.git/
Created fresh repository.
Checking out 45357a2a as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
Using docker image sha256:c4825e3ad0feedc9c2c39d218e408249514f4409d2e7c91702587931a0450477 for ruby:2.7 with digest ruby@sha256:5a81b132459c16a2b5d6b2741099de7c6209c545cbfd8539e3c501eb13cd5ca5 ...
$ touch test.txt
Uploading artifacts for successful job
00:01
Uploading artifacts...
WARNING: ../zd365279_artifact_path: no matching files. Ensure that the artifact path is relative to the working directory (/builds/clsb_user_02/zd365279_artifact_path) 
ERROR: No files to upload                          
Cleaning up project directory and file based variables
00:01
Job succeeded

Environment description

config.toml contents
Add your configuration here

Used GitLab Runner version

Version:      15.8.0
Git revision: 12335144
Git branch:   15-8-stable
GO version:   go1.18.9
Built:        2023-01-19T03:18:22+0000
OS/Arch:      linux/amd64

Possible fixes

  • A workaround would be using $CI_PROJECT_DIR/* in the job artifacts path.