Conditional flow control or logical statement support in GoCD for build breaking or quality gates

23 views
Skip to first unread message

Sekhar Routray

unread,
Jun 12, 2020, 3:37:24 AM6/12/20
to go-cd
Hi,

I'm quite new to GoCD and I'm trying to figure out if it possible to break a build pipeline or forcibly fail a pipeline based on a condition?

My exact requirements are to declare a threshold variable and if that threshold is crossed the stage/pipeline is to be failed forcibly and the subsequent execution of pipeline is stopped.

And if there are conditional statements(like if else) or support for logical statements(like &,&&,|,||,<,<=,>,>= etc) it makes the job easier for me as I can control the flow control to stages or other pipelines.

Thanks in advance.

Regards,
Sekhar Routray

kritik...@thoughtworks.com

unread,
Jun 12, 2020, 5:35:37 AM6/12/20
to go-cd
Hi Sekhar,

GoCD fails a job when a given task fails, i.e. if you execute a command which result in a non-zero value - the task has failed and so the job will fail.
E.g. 
<exec command="/bin/bash">
                <arg>-c</arg>
                <arg>if [ \"${SHOULD_FAIL}\" != 'true ]; then echo \"Failing the job\"; exit 1; fi</arg>
 </exec>

Hope this helps!

Kritika

Sekhar Routray

unread,
Jun 12, 2020, 5:54:15 AM6/12/20
to go-cd
Hi Kritika,

Thanks for this tidbit. This does help.

Regards,
Sekhar Routray
Reply all
Reply to author
Forward
0 new messages