Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the return value of xcodebuild?

Tags:

xcodebuild

I'm using xcodebuild inside a bash script on a continuous integration server.

I would like to know when a build as failed in the script, so I can exit prematurely from it and mark the build as failed.

xcodebuild displays a BUILD FAILED message to the console, but I don't succeed in getting a return value.

How can I achieve this?

Thanks in advance

like image 941
Emidee Avatar asked Sep 09 '11 14:09

Emidee


2 Answers

You can use the "$?" variable to get the return code of the previous command.

xcodebuild -...
if [[ $? == 0 ]]; then
    echo "Success"
else
    echo "Failed"
fi
like image 25
Dmitry Avatar answered Sep 21 '22 04:09

Dmitry


xcodebuild always returns 0, regardless of the actual test result. You should check for either ** BUILD FAILED ** or ** BUILD SUCCEEDED ** in the output to know whether tests pass or not.

like image 200
Javier Soto Avatar answered Sep 19 '22 04:09

Javier Soto