running next stage despite previous stage failing

39 views
Skip to first unread message

pan...@mammoth.io

unread,
May 24, 2022, 3:15:24 AM5/24/22
to go-cd
We have a few stages in one go pipeline. We want to run the subsequent stages even if the previous stage ends in failure. How do we do this?

Sriram Narayanan

unread,
May 24, 2022, 3:24:02 AM5/24/22
to go...@googlegroups.com
On Tue, May 24, 2022 at 3:15 PM 'pan...@mammoth.io' via go-cd <go...@googlegroups.com> wrote:
We have a few stages in one go pipeline. We want to run the subsequent stages even if the previous stage ends in failure. How do we do this?

To clarify, a stage can have multiple jobs that run in parallel, while stages run serially. If even one job in a stage fails, then that stage is considered to have failed.

So if you want a consecutive stage to run even if the earlier stage fails, then you need to ensure that the jobs in that stage always pass. You can do this by capturing the actual error and exiting from that job's shellscript with a zero (exit 0).
 

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/d5dedba5-e25c-4532-808a-9a05a23bcc22n%40googlegroups.com.

pan...@mammoth.io

unread,
May 24, 2022, 3:29:51 AM5/24/22
to go-cd
Hmm, ok
But this would make the preceding stage look all green. We don't want that.

I would like to explain why we do this. They ideally can be jobs that run in parallel, but we can't do this because of the extreme load it creates on the system under test. This makes us run them as stages. 

-Pankaj

Chad Wilson

unread,
May 24, 2022, 11:22:58 AM5/24/22
to go...@googlegroups.com
Another alternative you could consider is to create them as parallel jobs within a single stage, but define each job as requiring a resource (which are essentially just tags) there is only one of. This could be a single static agent which is tagged with a "resource", e.g "load-test-lock", or perhaps an elastic agent profile which has a maximum of a single agent. This will mean only one of the jobs will run at a time, and when the single agent frees up, the next job will be scheduled.

Other than that, with the loss of high level progress/visualisation you could perhaps merge them all into a single stage/job with either
  • multiple tasks (and task Run If Condition: Any) - i can't recall off the top of my head how the overall job status is determined in such a case, so you might need to check that
  • combine into a single task, and orchestrate it with a script, however you would like. You would aggregate the results at the end and fail the script if any one of the steps fails.

-Chad

Pankaj Ratan Lal

unread,
May 24, 2022, 11:36:43 AM5/24/22
to go...@googlegroups.com
Hi Chad,

Thanks for your response. Your answer seems to validate what we started to pursue today.

We are working to get the option 1 going for us, with some more exotic stuff. So we have first stage - at the end of which we would call go apis to set a resource on the agent which ran the first stage and same resource for all the jobs within a single 2nd stage and then achieve exactly the same results as you have suggested. At the end of it, we clear the resource from the agent by calling go apis.

I hope this would work.

Warm regar
You received this message because you are subscribed to a topic in the Google Groups "go-cd" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/go-cd/FYiDmmvTslw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/CAA1RwH8-kf3Y35kYHbyApi1HtuYie0E00C2U0nxn2v8w9eV_YQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages