Docker image build failed

CI says that it cannot find the jar file during docker build.
But the jar file is there when I do an ls -l

I am using a gitlab runner with docker socket binding configuration. Here’s the config:

concurrent = 1
check_interval = 0

  session_timeout = 1800

  name = "main"
  url = ""
  token = "eHppp1j5KtcJwfjKz_wz"
  executor = "docker"
    Insecure = false
    tls_verify = false
    image = "docker:20.10.16"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0

Here’s the console output:

e[0KRunning with gitlab-runner 15.2.0 (7f093137)e[0;m
e[0K  on main eHppp1j5e[0;m
e[0Ke[0Ke[36;1mPreparing the "docker" executore[0;me[0;m
e[0KUsing Docker executor with image ...e[0;m
e[0KAuthenticating with credentials from job payload (GitLab Registry)e[0;m
e[0KPulling docker image ...e[0;m
e[0KUsing docker image sha256:b84dc13e92d683ec0c9be6e100460569f893de15f6623566a8aecc51506264cf for with digest ...e[0;m
e[0Ke[0Ke[36;1mPreparing environmente[0;me[0;m
Running on runner-ehppp1j5-project-37926501-concurrent-0 via 2a1cd9ec1e86...
e[0Ke[0Ke[36;1mGetting source from Git repositorye[0;me[0;m
e[32;1mFetching changes with git depth set to 20...e[0;m
Reinitialized existing Git repository in /builds/my-portfolio11/simplilearn/capstone-project-3/.git/
e[32;1mChecking out b95c9721 as main...e[0;m
Removing .m2/
Removing target/

e[32;1mSkipping Git submodules setupe[0;m
e[0Ke[0Ke[36;1mDownloading artifactse[0;me[0;m
e[32;1mDownloading artifacts for build-jar (2750380883)...e[0;m
Downloading artifacts from coordinator... ok      e[0;m  ide[0;m=2750380883 responseStatuse[0;m=200 OK tokene[0;m=6nK4891X
e[0Ke[0Ke[36;1mExecuting "step_script" stage of the job scripte[0;me[0;m
e[0KUsing docker image sha256:b84dc13e92d683ec0c9be6e100460569f893de15f6623566a8aecc51506264cf for with digest ...e[0;m
e[32;1m$ ls -l target/e[0;m
total 39476
-rw-r--r-- 1 root root 40420729 Jul 21 06:11 springboot-thymeleaf-crud-web-app-0.0.1-SNAPSHOT.jar
e[32;1m$ docker build -t $DOCKER_REGISTRY/$APP_NAME:$CI_PIPELINE_IID .e[0;m
Sending build context to Docker daemon  1.644MB

Step 1/5 : FROM openjdk:11-jre-slim
11-jre-slim: Pulling from library/openjdk
461246efe0a7: Pulling fs layer
e693ef00b582: Pulling fs layer
75f2c7b97846: Pulling fs layer
1f5a2a251760: Pulling fs layer
1f5a2a251760: Waiting
75f2c7b97846: Download complete
e693ef00b582: Verifying Checksum
e693ef00b582: Download complete
461246efe0a7: Verifying Checksum
461246efe0a7: Download complete
461246efe0a7: Pull complete
1f5a2a251760: Verifying Checksum
1f5a2a251760: Download complete
e693ef00b582: Pull complete
75f2c7b97846: Pull complete
1f5a2a251760: Pull complete
Digest: sha256:d9ecefcab746db9db18aac10c94b796ae3e0ef9c2a60194b8f7e034fc02b1113
Status: Downloaded newer image for openjdk:11-jre-slim
 ---> 699c24828c34
Step 2/5 : ARG jar_file="target/*.jar"
 ---> Running in 1dba87b89435
Removing intermediate container 1dba87b89435
 ---> edffc62b6d3e
Step 3/5 : COPY ${jar_file} /app.jar
COPY failed: no source files were specified
e[0Ke[0Ke[36;1mCleaning up project directory and file based variablese[0;me[0;m
e[0Ke[31;1mERROR: Job failed: exit code 1

Does the CI user have read access to the file?

Not sure.
I have installed gitlab-runner as a docker container using the following command:

docker run -d --name gitlab-runner --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v gitlab-runner-config:/etc/gitlab-runner \

My Gitlab repo is Public. Here it is:

Now I have added a stage for deploying to the gitlab container registry. But…

$ ls -l target/
total 39476
-rw-r--r--    1 root     root      40420729 Jul 23 10:13 springboot-thymeleaf-crud-web-app-0.0.1-SNAPSHOT.jar
$ printf "$CI_DEPLOY_PASSWORD" | docker login -u $CI_DEPLOY_USER --password-stdin $CI_REGISTRY
Error: Cannot perform an interactive login from a non TTY device
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

Just to be clear, it’s the Jar file you want to upload to a GitLab registry? The container registry is really for Docker images / containers. For Jar files, the package registry is the one you’re looking for. There are docs for using the package registry with Maven that might be useful to you.