Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the Console Output for a specific string and raise an error on the Build?

I have Hudson configured for building a project.

And the console output, after building is, as follows:

Compiling ./main.py ...
Sorry: IndentationError: ('expected an indented block', ('./main.py', 8, 6, 'thread.start_new_thread( foo.FooThread, () )\n'))
Compiling ./udpReceiver.py ...
<<<<< build finished!
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0

Deleting project workspace... 
done

Finished: SUCCESS

As you can see, I have an Indentation Error....and Hudson says that the build job finished with success.

What I want is something like this:

Check if the string "IndentationError" is presented on the console output text ... if so, than the build should be: Finished: FAILED!!!!!!!!

How can I accomplish this?

like image 729
waas1919 Avatar asked Dec 02 '25 07:12

waas1919


1 Answers

I confirm that the Log Parser plugin can do the job to change the build status to failure.

Install the plugin and create a rule set for your Python build for example:

enter image description here

In the create the /var/lib/jenkins/logParserRules/python-error file:

error /IndentationError/

Next, update the Python build with these settings:

enter image description here

The build status will be changed to FAILURE:

Compiling ./udpReceiver.py ...'
Sorry: IndentationError: ('expected an indented block', ('./main.py', 8, 6, 'thread.start_new_thread( foo.FooThread, () )\n'))
Compiling ./udpReceiver.py ...
Build step 'Console output (build log) parsing' changed build result to FAILURE
like image 165
Bruno Lavit Avatar answered Dec 05 '25 01:12

Bruno Lavit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!