gitlab build job upload artifacts ERROR: No files to upload

554 Views Asked by At

I'm dealing with an issue on gitlab pipeline. My build job seems to went well but i'm unable to upload my artifact .rpm to gitlab even with the good path.

.gitlab-ci.yml

build:
  stage: build
  image: centos
  script:
    - set -x
    - various steps ... 
    - cd ~
    - tree
  artifacts:
    paths:
      - rpmbuild/RPMS/x86_64/*.rpm

error message .

|-- anaconda-ks.cfg
|-- anaconda-post.log
|-- original-ks.cfg
`-- rpmbuild
    |-- BUILD
    |   `-- ***** 
    |-- BUILDROOT
    |-- RPMS
    |   `-- x86_64
    |       `-- project-0.1-1.el8.x86_64.rpm
    |-- SOURCES
    |   `-- project-0.1.tar.gz
    |-- SPECS
    `-- SRPMS
        `-- project-0.1-1.el8.src.rpm
17 directories, 37 files
Uploading artifacts for successful job 00:00
Uploading artifacts...
WARNING: rpmbuild/RPMS/x86_64/*.rpm: no matching files. Ensure that the artifact path is relative to the working directory (/builds/firstnameName/project) 
ERROR: No files to upload                          
Cleaning up project directory and file based variables

Any advice would be appreciate

What I tryed :

  • debug in gitlab-ci job build
  • various ways to trigger the .rpm
  • $CI_PROJECT_DIR
  • /project-*.rpm
  • *.rpm
1

There are 1 best solutions below

1
Raghu On BEST ANSWER

The problem is your rpmbuild folder is not under "$CI_PROJECT_DIR" rather it is in the "home" directory of the Gitlab runner.

"~"(home directory) != $CI_PROJECT_DIR(gitlab project directory).

They are completely different direcories.

For the artifact path to be recognized you will have to create or move your rpmbuild directory into $CI_PROJECT_DIR. Below I have added a copy command to copy rpmbuild to $CI_PROJECT_DIR

build:
  stage: build
  image: centos
  script:
    - set -x
    - various steps ... 
    - cd ~
    - cp -R rpmbuild $CI_PROJECT_DIR/ 
  artifacts:
    paths:
      - rpmbuild/RPMS/x86_64/*.rpm

You could move the folder as well instead of copy, it is up to you.