# Fail if an artifact doesn't exist on upload

**URL:** <https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433>\
**Category:** Features Requests\
**Created:** [April 15, 2019, 8:39pm UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433 "2019-04-15T20:39:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan.pierce](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/nathan.pierce/32/393_2.png) [@nathan.pierce](https://forum.buildkite.community/u/nathan.pierce)\
**Post date:** [April 15, 2019, 8:39pm UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/1 "2019-04-15T20:39:10Z")

</div>

Is there a way to ensure artifacts exists before giving a success to the step? I’d like to avoid [[-f ARTIFACT]] checks in the commands area.

We’re doing a tar of a build directory and sometimes that doesn’t work properly. We’d like to avoid it proceeding on if that fails.

---

<div class="post-metadata">

**Author:** ![anon46008679](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@anon46008679](https://forum.buildkite.community/u/anon46008679)\
**Post date:** [April 18, 2019, 12:08pm UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/2 "2019-04-18T12:08:11Z")

</div>

Good question! The `buildkite-agent artifact download` command will through an error if there was no artifact found. Are you not finding that to be the case?

---

<div class="post-metadata">

**Author:** ![nathan.pierce](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/nathan.pierce/32/393_2.png) [@nathan.pierce](https://forum.buildkite.community/u/nathan.pierce)\
**Post date:** [April 18, 2019, 2:19pm UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/3 "2019-04-18T14:19:23Z")

</div>

That’s too late in the process for us. Need it to fail immediately on the step that attempts the upload

---

<div class="post-metadata">

**Author:** ![anon46008679](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@anon46008679](https://forum.buildkite.community/u/anon46008679)\
**Post date:** [April 22, 2019, 1:43am UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/4 "2019-04-22T01:43:50Z")

</div>

Oh, I didn’t realize you were referring to artifact uploads. Sorry, I thought you meant downloads.

Are you using the `buildkite-agent artifact upload` command, or using the `artifact_paths` in the step’s configuration?

---

<div class="post-metadata">

**Author:** ![nathan.pierce](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/nathan.pierce/32/393_2.png) [@nathan.pierce](https://forum.buildkite.community/u/nathan.pierce)\
**Post date:** [April 22, 2019, 9:46am UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/5 "2019-04-22T09:46:04Z")

</div>

Apologies, you’re absolutely right about that not being clear.

Currently, we’re using `artifact_paths: "build.tar.gz"`

---

<div class="post-metadata">

**Author:** ![anon46008679](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@anon46008679](https://forum.buildkite.community/u/anon46008679)\
**Post date:** [May 7, 2019, 4:29am UTC](https://forum.buildkite.community/t/fail-if-an-artifact-doesnt-exist-on-upload/433/6 "2019-05-07T04:29:52Z")

</div>

Thanks! That makes sense.

I don’t think we’d make a change with the currently pipeline.yml syntax to have it fail the job, because too many people rely on the current behaviour as a grab bag of glob patterns that don’t affect the job status.

But if we update the artifact upload/download syntax in a future version of the pipeline.yml format, we’ll take this into account!
