Can't SCP with wildcard

Summary

I am trying to use SCP with wildcards in a job but the runner fails because SCP return that it couldn't find the directory.

I tried running SCP with singles quotes, double quotes or without quotes and the result is always the same. Running the command on other server (VPS with Ubuntu) sends the files without problems.

Steps to reproduce

.gitlab-ci.yml

stages:
 - copy

copy:
  stage: copy
  script:
    - 'which ssh-agent || (apt install openssh-client -y)'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - mkdir updated_files
    - mkdir updated_files/subdir
    - touch updated_files/somefile.txt
    - touch updated_files/subdir/otherfile.txt
    - ls -la "$CI_PROJECT_DIR/updated_files"
    - scp -r "$CI_PROJECT_DIR/updated_files/*" user@host:/dst_path    

What is the current bug behavior?

The Job log shows the following:

$ ls -la "$CI_PROJECT_DIR/updated_files"
total 28
drwxr-xr-x. 3 root root 4096 Nov 22 11:37 .
drwxrwxrwx. 7 root root 4096 Nov 22 11:37 ..
-rw-r--r--. 1 root root    0 Nov 22 11:37 somefile.txt
drwxr-xr-x. 2 root root 4096 Nov 22 11:37 subdir
$ scp -r "$CI_PROJECT_DIR/updated_files/*" user@host:/dst_path
Warning: Permanently added the RSA host key for IP address 'XXX.XXX.XXX.XXX' to the list of known hosts.
/builds/username/project/updated_files/*: No such file or directory
ERROR: Job failed: exit code 1

What is the expected correct behavior?

SCP to copy the files correctly

Output of checks

This bug happens on Gitlab.com

Assignee Loading
Time tracking Loading