I am just wondering how to send out email with Email-ext plugin based on each build step result on same Jenkins Job. Here is my scenario
My Jenkins job has 3 Build s
Instead of customizing email ext consider breaking up job into 2 jobs:
For both jobs set job parameters in (job)/Configure/Advanced Project Options to
If you'd also like to attach test results to job 1 in case it was successful, add in post build steps in job 1 Aggregate downstream test results.
In a normal configuration, if Build Step 1 fails, Build Step 2 will not execute anyways.
And if Build Step 2 (Test) fail, the build will be marked "Unstable", not "Failed".
Email-ext already supports triggers for these.
You want to configure a trigger for "Failure" and a trigger for "Unstable" (you will also probably want a trigger for "Success")
In your "Failure" trigger, write the email content you want for when the build fails (Build Step 1 failure will cause this for you).
In your "Unstable" trigger, write the email content you want for when the test cases fail.
In your "Success" trigger, write the email content you want for when everything was successful and you want to send the test report.
Alternative:
Or you can look into Any Build Step plugin (which should allow post-build actions, like email-ext, to be executed as a build step), and Conditional Build Step plugin (which allows to create conditions for each build step). Combine the two and create conditions when you want to trigger the email-ext build step. However I have not tried this and can't guarantee this will work.