When there're no artifacts collected, disable "Download" button and do not generate an empty .zip

Summary

When an artifact pattern has been defined but there's no matching files to upload in a job:

Uploading artifacts...
WARNING: ./*.txt: no matching files                
Uploading artifacts to coordinator... ok            id=<job_id> responseStatus=201 Created token=<token>
Job succeeded

GitLab CI still allows to download the artifact archive.

Steps to reproduce

  1. Define a pattern that won't match any generated files on the job.
  2. Run the pipeline
  3. Click on "Download" in the Job Artifacts section or wget https://gitlab.com/<user>/<project>/builds/<job_id>/artifacts/download

What is the current bug behavior?

The "Download" button is available everywhere (i.e. pipeline, job, artifact explorer views...), even when there's nothing to be downloaded:

Screenshot_2017-04-10_09.50.56

And it allows to download the zipped contents; which will cause an error with OS X's Archive Utility as the file cannot be expanded:

What is the expected correct behavior?

  • The "Download" button could include a tooltip explaining there was no matching files generated in the job to prevent downloading 22 bytes .zip files with no content.
  • The API endpoint to download the artifacts (/<job_id>/artifacts/download) could return a 204: No Content when queried.

Output of checks

This bug happens on GitLab.com

Assignee Loading
Time tracking Loading