Tweaking Jenkins Result using Plugin Text Finder



Hi Friends,

 I am writing this blog because I couldn’t find a proper article or tutorial for tweaking Jenkins result. StackOverflow and similar kinds of links were just asking me to use a Jenkins plugin -TextFinder.


Other than a brief description, the wiki doesn’t provide enough details, might be the developers would have felt as it is simple and self explanatory.

So via this blog, I am trying to explain how to tweak Jenkins results using text finder plug-in. How to get a blue build even if your test case fails.

The initialization of this plug-in is similar to other Jenkins plug-in. So let us directly talk about configurations required. Before that let me give you my problem statement and solution we were looking for.

Problem statement: - We were looking to customize email configuration for a particular Jenkins Job depending on certain condition. To be more specific, we were checking whether  a particular text or pattern appears in our report file 

Our Existing system:-
Our smoke automation Job contains 4 testcases. Currently even if 1 testcase fails, the build will turn red and it will notify all the stake holders via email. The stake holder contains Level 1 support team also. We don’t want other team to be notified until and unless a real blocking issue. This is because our automation scenario also covers different 3rd party webpage’s whose UI changes without any notice.

New requirement:-
According to our new requirement it should notify only if all test cases fails.

 We used the Jenkins Text Finder for achieving this:- 

Once installed, the Jenkins Plug-in will appear under Post-build Actionsà Jenkins Text Finder.

Give the filename in the Jenkins Text Finder text field where you want search the pattern
In my case I was looking for failures="0-3" in the file /target/surefire-reports/TEST-TestSuite.xml .
The first line of this file will be  
<testsuite name="TestSuite" time="664.364" tests="4" errors="0" skipped="0" failures="2">


Also provide the proper regular expression in the Regular expression text field.

In my case :- It will verify the above file for text ‘failures’, i.e.  if “failures<=[0-3]” make the build pass and if “failures =4” make the build fail and notify everyone on the mailing list.

PFB the screenshot for more details.



Other than the above you may also need to set the ERRORLEVEL to '0'. For example,  the Windows shell if it is a windows server  will returns ‘failure’ if  one tests fails, so we need to ignore that error level by forcing ERRORLEVEL=0 as it exits the shell guid part.




Regards,
Bala




No comments:

Post a Comment