Is there a way to make the artifacts plugin fail if it finds nothing to upload?

Hi. We have a pipeline step that uses the artifacts plugin like so:

      - artifacts#v1.9.2:
          upload:
            - helm/revisions/*

Due to a recent bug in the script called by this step, it failed to produce the files we wanted to upload into the /helm/revisions/ path.

This results in the artifacts upload step showing:
image

So despite not finding anything to upload, the status is INFO and green, and the step completes successfully.

For us, this step creates content that is used by a rollback step that can be manually unblocked later in the pipeline.
We had the need to perform a rollback recently and it failed to run due to these missing artifacts.

Is there a way to (or can a way be provided) to set an option to abort with an error if the upload cannot be performed?

Hey Jim :wave:

Welcome to the community!

I had a look, we have a flag called ignore-missing in the artifact plugin which allows you to fail the step when artifacts are not found. But it is currently scoped only for artifact download. I’m raising internally to extend it to upload so scenario like yours can be achieved.

However in the meantime, as a work around, you can fail the upload step by doing a check in repo level pre exit hook like below,

if [ “$BUILDKITE_LABEL” == “artifact-upload” ]; then

buildkite-agent artifact search helm/revisions/*

fi

It will fail the step if artifacts are not found.

Hope this helps, let us know if any questions.

Cheers,
Priya

Thank Priya.

Will that solution work if we upload artifacts in other steps that deal with different files?
That hook would be at the repo level, not the step level right?

Hey Jim,

Yes, the hook is at repo level but in the pre-exit implementation you can add conditions for each step.

So whenever pre-exit runs for a particular step if it matches your condition with $BUILDKITE_LABEL == “step name” it should run the search for the artifact path you explicitly set in the condition.

Let me know if this helps.

Cheers
Priya

Ok thanks.