Attribute when on_fail does not work with store_artifacts

I’m using the following bit of config:

      - run:
          name: Creating failure artifact to assist with debugging
          command: |
            zip -r ~/failed-build.zip .
          when: on_fail
      - store_artifacts:
          name: Uploading failure artifact to assist with debugging
          path: ~/failed-build.zip
          destination: failed-build.zip
          when: on_fail

The run command is only executed when the build has failed as expected. But the store_artifacts command always runs whether the job is succeeding or failing. I assume this is simply a bug.

1 Like

I think it was more a design discussion to always run when exists, but I agree that if that’s the case we should pass an error if we see the when: that we aren’t going to honor it. I’ll have to check if this is a feature or a bug.

To be clear, you want artifacts only on fail, correct?

Yes, I want artifacts to be uploaded on “on_fail”. The use case is exactly as shown - to build a zip representing the failed state of the server to avoid having to login via SSH. I think its a very valid use case.

I agree that it is. My question was more to the desire to only upload on fail, vs always.

If you vote on the feature request here https://ideas.circleci.com/ideas/CCI-I-573 our product team will able to gauge interest and prioritize and you will recieve updates on the progress.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.