Reputation: 4016
I am attempting to write a custom pre-send script for Jenkins email-ext plugin. I'm at the point where I can write a simple 'hello world' groovy script and run it with the "Email template testing" tool for the job I want to customize.
Alas, I'm having a bit of trouble navigating Jenkins build API. As a starting point, the job whose email I want to customize has N
build steps. I only want to send an email if one of those steps faild, and I'd like to write a different message depending on which step failes.
How can determine the number of steps in the build (N
), and which step failed?
Upvotes: 1
Views: 822
Reputation: 111623
Which build step caused the build result to change is only recorded in the console output, e.g.
Build step 'Execute shell' marked build as failure
This isn't otherwise stored as part of the build record, and so isn't available via the API.
So you would have to try scraping the console output to do what you want.
To determine how many build steps there are, you'd need to fetch the job configuration via /job/foo/config.xml
and count how many items there are within the <project><builders>
tag (assuming a freestyle project).
Upvotes: 0