Reputation: 21018
I have some code I run against other code. Let say command x runs code blah.c
I have written a script to check to see if that command executed successfully. I am able to determine this. I will be running the script in the execute build box available in hudson.
I need to know who to fail the build if any of there code tests fail. meaning command x ran on blah.c returned in failure.
Best practices for jobs not built by maven. Is it possible to integrate maven?
Please and thank you.
Upvotes: 2
Views: 2111
Reputation: 3609
Yes, you can use the M2 Extra Steps plugin for hudson in order to issue shell commands prior/after your maven build, with conditional control (eg, if this command fails, skip running Maven, aborting the build)
We use that in order to cleanup some stuff prior to running the build.
Upvotes: 0
Reputation: 15972
If you're running a shell script, you can indicate failure by exiting with a non-zero error code.
run_my_command foo
if [ $? -ne 0 ]; then
echo "run_my_command failed"
exit 1
fi
I agree with @ircmaxell that there are better ways to write build scripts than writing shell scripts directly in Hudson.
Upvotes: 2
Reputation: 165193
Personally, I use either ANT or Phing for this kind of thing. You can specify the steps necessary to complete a "target".
So in your case, you'd specify an exec
task. Then, you'd set the checkreturn
property on that task. So that way, if the command returns anything but 0
, it'll fail the target. And Hudson will automatically fail the build.
The nice thing about this, is that you can manually execute the ANT
build task outside of Hudson (so you don't need to commit to verify if it will build successfully). I personally keep my phing build.xml file inside the same version control as my project so that I always have it available...
Upvotes: 1