# Options for running the "store\_artifacts" step conditionally

**URL:** <https://discuss.circleci.com/t/options-for-running-the-store-artifacts-step-conditionally/54147>\
**Category:** API\
**Tags:** artifacts\
**Created:** [October 9, 2025, 12:37am UTC](https://discuss.circleci.com/t/options-for-running-the-store-artifacts-step-conditionally/54147 "2025-10-09T00:37:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjerdonek](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cjerdonek/32/33589_2.png) [@cjerdonek](https://discuss.circleci.com/u/cjerdonek)\
**Post date:** [October 9, 2025, 12:37am UTC](https://discuss.circleci.com/t/options-for-running-the-store-artifacts-step-conditionally/54147/1 "2025-10-09T00:37:39Z")

</div>

Hi, I have a question as to what options there are for setting up a configuration file to run a [`store_artifacts`](https://circleci.com/docs/reference/configuration-reference/#storeartifacts) job step conditionally, but on a condition that depends _on a value known only at runtime and not at compile-time_.

If I wanted to do this based on a value that’s known at compile-time, I know I can use `when` with `condition`. However, for values known only at runtime, my understanding is this approach can’t be used. Thus, my question is — what alternatives are there?

The only approach I’ve thought of so far is to make `store_artifacts` the last step in the job, and then to insert a step before this that runs [`circleci-agent step halt`](https://support.circleci.com/hc/en-us/articles/360015562253-Conditionally-End-a-Running-Job-Gracefully) conditionally on an environment variable whose value is computed at runtime. (I haven’t actually tried this yet, but I’m assuming it will work.)

Are there any other approaches? The above approach doesn’t seem ideal because it requires `store_artifacts` to be the last step (since `circleci-agent step halt` stops the job). Thanks in advance.
