Workflows: Run a dependent job regardless of success



Job B depends on Job A. I’d like to run Job B after Job A is complete, whether or not Job A was successful. Is that possible?



If you can make it a step, you can use the when keyword:


Thanks, Marc! I didn’t know about the when keyword. In fact I have three Jobs, build-linux, build-mac, and collect-artifacts. As you can guess, build-linux runs on Linux, and build-mac runs on macOS, so I can’t put them in the same job. I want collect-artifiacts to run whether or not build-linux and build-mac were successful. It sounds like this issue has become a feature request. I’d love to see the when keyword added to workflows.



Meanwhile maybe you could move the collect-artifacts job to a step and copy it to both build-linux and build-mac, so you are able to use the when keyword? I understand that’s not ideal, though.


That’s what I had originally, in fact. I have a downstream step that uses the CircleCI API to download the artifacts of the latest build of a particular PR number using…

    api_url = "{slug}/latest/artifacts?branch=pull/#{issue}"

The latest keyword gives me the artifacts of the most recent build, whereas I need the artifacts of all the builds of the most recent run of a workflow. Is there an API call either to get the build numbers of the most recent run of a workflow of a particular branch, or to get all the artifacts of the most recent run of a workflow?



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