Null build finish date for SRunningBuild that has completed

When creating a notifier plugin, the notifyBuildFailed and notifyBuildSuccessful methods are invoked by the server with an SRunningBuild parameter, presumably these builds have completed. However calling getFinishDate() for these parameters returns null.

Here's the snippet where I am getting the finish date in my plugin:
public BuildAlertPayload(NotificationType type, SRunningBuild build, Set<SUser> alertRecipients) {
String buildEndTime = build.getFinishDate() == null ? null : build.getFinishDate().toString();

The SRunningBuild param is passed in from notifyBuildSuccessful or notifyBuildFailed.

Is this not the proper way to get the completed time?

Relevant java doc:


java.util.Date getFinishDate()
Returns finish timestamp for the build (server time) or
if it hasn't been finished yet.

Date/time when the build has been finished,
if still running.

Comment actions Permalink


Instance of Runnig build will always return "null" for the finishe date.
What you can do is to find a finished build by the build id and use the found finished build to get related data.
Like buildsManager.findBuildInstanceById(runningBuild.getBuildId())

Comment actions Permalink

Hi Yegor, sorry for the late reply.

How do I initialize an instance of BuildsManager so that it will work correctly? findBuildInstancesById doesn't appear to be a static method and the class is abstract.

Comment actions Permalink

I solved this by adding a BuildsManager parameter to my NotificatorAdaptor's constructor - this got picked up by the spring autowiring and I was able to use it to solve my problem as Yegor described.


Please sign in to leave a comment.