Backend: Job succeeds despite the fact that artifact was not found

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When running a ci job with declared artifacts, if the job can not build the artifact, then the artifact is not found at upload time. In that case, I believe job should be marked as failed but it is considered successful.

As a result, one can introduce a regression in its build process without discovering it before days or client reporting incapacity to download artifact.

There's a similar issue open in the runner project that may resolve this issue.

Steps to reproduce

Define a job in .gitlab-ci.yml which is supposed to build an artifact but does not. Wait for the CI to run and observe that the job has succeeded eventhough no artifact has been published.

I built a sample job that should have failed but succeeded.

Here is a .gitlab-ci.yml to reproduce:

build:
  script:
   - echo do not build artifact
  artifacts:
    paths:
      - /tmp/unexisting_artifact.zip

The script itself won't fail but the build should since the declared artifact can not be found.

Example Project

https://gitlab.com/pascal_legolas/job_should_fail

Proposal

Implement the following gitlab ci yaml syntax:

# MVC
artifacts:
  paths:
    - "dist/*.zip"
    - "docs/**/*.pdf"
    - "reports/coverage.xml"
  require: true  # default: false (backward compatible) -- Job fails if ANY pattern produces zero matches

Relevant logs and/or screenshots

See sample job.

Output of checks

This bug happens on GitLab.com

Edited by Allison Browne