Backend: Job succeeds despite the fact that artifact was not found
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=22711) </details> <!--IssueSummary end--> <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "bug" label. For the Community Edition issue tracker: - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=bug For the Enterprise Edition issue tracker: - https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=bug and verify the issue you're about to submit isn't a duplicate. ---> ### 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](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4240) 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](https://gitlab.com/pascal_legolas/job_should_fail/-/jobs/74277131) 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: ```yaml # 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](https://gitlab.com/pascal_legolas/job_should_fail/-/jobs/74277131). ### Output of checks This bug happens on GitLab.com
issue