My build/deploy script does not behave as I was expecting. If clone or build fails it will still go on and call restart. I suspect its because I return 0, but how should I write if I want to return the result from the inner commands, and in "clone" I want to move into the cloned folder only if clone was successful. How would you improve this script?
function clone {
git clone /volume1/repos/project.git
cd project
return 0
}
function build {
docker build -t project .
return 0
}
function cleanup {
...
}
function restart {
...
docker run ...
}
trap cleanup EXIT
if clone && build; then
restart
exit 0
else
echo Failed...
exit 1
fi