5

Question

Is there a way to detect if an ant retrieve call fails due to a login issue?

Background

I've got a pretty basic bash script that uses ant to retrieve the latest changes from our production instance and commit them to a git repo. In order to get track deletions I have to first clear out the src folder since retrieve leaves deleted components behind. Problem is if their is any failure with the retrieve call it commits with an empty folder. How can I get my script to exit if the retrieve call fails?

3
  • Can you post a fragement of your Ant script. I've just tried a sf:retrieve ant call and it does stop the Ant build script when a login error occurs. Have you got some try/catch logic someplace in your script perhaps? Nov 9, 2013 at 10:14
  • Ant's -verbose (and -debug and -diagnostics) command-line options are worth trying when an Ant task is not doing what you expect so that you can see detail of the internal steps.
    – Keith C
    Nov 10, 2013 at 10:11
  • The ant task was working as expected. Just needed the downstream part of a bash script to be able to act conditionally based on whether the ant build failed or not. Nov 10, 2013 at 21:13

1 Answer 1

3

There are two ways you can control this:

1) You can check the error code from the ant run. If the error code is not 0, there was an error. For example, something like this should work (*nix):

ant retrieve
if [ "$?" = "0" ]; then
    # commit;
else 
    echo "Failed to retrieve, skipping commit.";
fi

2) You can commit in the ant target directly using the ant exec command; if the retrieve fails, the commit will never occur.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .