Stop job when artifacts not exist

Hey Forum,

We have a project where we deploy the application via GitLab. For the project we generate CSS, JS and other frontend files via “npm install” and then “npm run prod”. After run prod, we put all the generated files into an artifact, so we can deploy the files at the last stage.


The problem was that the job (npm run prod) succeded, but there were no artrifacts uploaded at all. Please, see attached image above.*


  • GitLab 15.2.2-ee
  • Runner: 15.2.1
  • GitLab Shell14.9.0
  • GitLab Workhorsev15.2.2
  • GitLab APIv4
  • GitLab Pages1.61.1
  • GitLab KAS15.2.0
  • Ruby2.7.5p203
  • Rails6.1.4.7
  • PostgreSQL12.10
  • Redis6.2.7

The Gitlab CI/CD stage in question:

  extends: .npm_run
    - npm install
    - npm run prod
    - master
  stage: build
  image: node:12.18.3
      - public/documents
      - public/audio
      - public/images
      - public/fonts
      - public/img
      - public/webfonts
      - public/js
      - public/css
      - public/static/css/jquery.cookiebar.css
      - public/static/js/jquery.cookiebar.js
      - public/static/js/cookie.policy.js
      - public/mix-manifest.json

Interestingly re-running the pipeline, the task succeeded without an issue.

We would like to implement a rule to STOP the whole pipeline if there are no artifacts available to upload. The reason is, our application got deployed to production environment but without any frontend. Can you tell me how can I achieve that please?

Thanks for taking the time to be thorough in your answers, it really helps! :blush:

Hi @bertalan.imre

There is no “native” way to check if any files are uploaded as part of the artifact. You can add another step after the npm run prod command to check that all required files are really there and fail the npm_run_prod job if not.

Thank you. I’ll do that. I somehow expected that there is no native way because I’m sure I would have found it by now. :smiley: