Hey everyone,
This is a follow up post to a discussion we had while attending the Jenkins CI code camp in Copenhagen.
Basically we have a plugin that has to be able to set the result of a build, and it has to be the final Judge in the overall result of the build, our build step only runs when the overall result is SUCCESS and our plugin should have the final-final say in the result of the proces.
We implemented it as a publisher, and I made the mistake of implementing and overriding the method below.
@Override
public boolean needsToRunAfterFinalized() {
return true;
}
This means that we do run after after the result of the build is final, but since our publisher itself can fail (we do Git stuff), we end up in the situation described here:
What makes this a bit tricky is that we actually programatically add our publisher during build if it isn't present
So i thought about solutions
- RunListeners (onCompleted(), onFinalized() - nope they're all after the build status has been set
- Change to Recorder, and set @Extension(ordinal = Double.MIN_VALUE) to add it to the very end of the publisher list
- ? Others
Solution 2 seems like a hack to me, and it does not prevent users from switching the order of the post build steps. It's also further complicated by the fact that we add the publisher in code during exection of our plugin.
So is there a way we can make sure we're the absolute last plugin to have a say in the finalized result of a build?
I took a look at how this was handled in for example the GitPublisher Plugin since it also has the option to only push on succesful builds, the solution they choose is #2 from above, but it seems kinda fragile as this can be moved around in the list after it has been added?
It lead to the discussion of the posibility of adding an optional 'Final Judge' slot in the job configuration, each job could only have one of those (having one at all would be optional)
Is my use case totally wrong here? Or is it something that could be of interest to others?
Best regards,
Mads