Hello, This is more about shell scripts than GoCD. In GoCD, any script which exits with a non-zero status code fails the job and hence the pipeline. If you run your script on the command-line and then run an "echo $?", it'll probably show a 0 (success), which is why the pipeline succeeds.
You need to use set -e <http://mywiki.wooledge.org/BashFAQ/105> or expect the errors and handle them. Here's another reasonable article <http://www.davidpashley.com/articles/writing-robust-shell-scripts/> about it. Cheers, Aravind On Tue, Sep 27, 2016 at 2:16 AM, Tin Huynh Cong <[email protected]> wrote: > Hello, > > I create a custom command task using /bin/sh to zip Angular Source Code > and then copy/deploy to another server by scp and ssh. > Here is the code sample > > #!/bin/sh > echo "Begin zip data..." > tar -czvf client.tar.gz * > > echo "Begin copying data ..." > scp client.tar.gz [email protected]:/opt/tomcat/webapps/ > > echo "Begin deleting old data ..." > ssh [email protected] rm -rf /opt/tomcat/webapps/client > > echo "Begin unzip new data ..." > ssh [email protected] mkdir -p /opt/tomcat/webapps/client > ssh [email protected] tar -zxvf /opt/tomcat/webapps/client.tar.gz -C > /opt/tomcat/webapps/client > > The problem is when one of the following tasks such as: zip, copy, unzip > failed, status of pipeline is still success > Question: > How to make status of a pipeline failed in case using custom command task ? > > Thanks, > Tin. > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
