Jenkins file code to send email notification on error
I need to run my test project in TestComplete14 every night, and I need to be able to send result (Succeeded/Error(s) occurred) as a part of a email subject. Currently, I run the test project in Jenkins as a scheduled nightly job and also use Jenkins file to send email notification for pass/fail build status .I want to go a step further and code Jenkins file to send email notification of Success if all test cases passed and Fail if there is given percentage of errors. I am having trouble to accomplish that. Can anyone help?
Below is the Jenkins file code, which I use currently for email notification for Build status -