In our simple script that's used in Hudson, We use ojdeploy -buildfile a.xml -define application.root=/root/test
It works fine when everything compiles but when it fails, the script continues executing with errors which leads to false build status as pass since the shell script runs to the end of file.

How to do use in the shell script with ojdeploy to give a non-0 error number in shell script when ojdeploy fails ?
Any simple concrete example would be great.

In your shell script, you should be able to get the result of the previous process using "$?". So you could evaluate that after calling ojdeploy and if that contains an error code, you should be able to exit your script.