I have set up a 'freestyle project' in hudson that checks my source-code out from a svn repository. Then I added a 'shell step' to build the code:
echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log
After running a test, hudson says t succeeded. When I look into the console output of the build I find:
In file included from src/tut.h:47,
from src/tut3module.cpp:1:
src/log.h:69: error: ‘uint8_t’ has not been declared
make: *** [obj/tut3module.o] Fehler 1
Finished: SUCCESS
Why does hudson not recognize this error? How do I have to configure the job?
L开发者_JAVA百科et me know if you need more information about my configuration!
Thanks for your help!
Hudson uses the error code of the build step to determine if the build step was successful or failed. Your whole build step will be converted to one script. If you don't call exit somewhere in the script the exit code of last command of the script becomes the exit code of the script.
See following script
copy readme.txt dd:
type readme.txt
Let's assume that readme.txt exists. The copy will fail with errorcode 1, because dd:
is an unknown device. The type command will succeed and therefore the build step itself will return a success. So either separate the build commands or check the error code after each command. A SysAdmin recommended a third approach to me: Run your script and check the results. So in your case, your build should have worked whenever your build artifacts exists.
Of course you can also use the log parser plugin as mentioned by sagar. But if you can avoid it, go with script that checks for error codes rather, then to rely on the log parser. BTW, there are commands that deviate from the standard and return a non-zero error code, even in a success case.
Hudson is not recognising the error probably because, in your build step, you are redirecting both the stdout and stderr for qmake and make to a log:
qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log
Try removing the redirects and see if that changes things. So:
echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake
make
In any case, you have a second option:
You could use this: http://wiki.hudson-ci.org/display/HUDSON/Log+Parser+Plugin
You can set it up to recognize words like 'error' and 'failed' and cause it to fail the build. It uses regex to detect words, so you have a lot of control over what it uses to detect the failure.
Try creating two separate build steps in hudson. Make the first step be the compile. the second step runs the steps. If any of those steps fail hudson should fail.
精彩评论