Workflows: Run a dependent job regardless of success

workflow

#1

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?

Thanks,
Shaun


#2

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

https://circleci.com/docs/2.0/configuration-reference/#the-when-attribute


#3

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.

Cheers,
Shaun


#4

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.


#5

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 = "https://circleci.com/api/v1.1/project/github/#{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?

Cheers,
Shaun


#6

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