Listen on unexpected finish

When a build is interrupted / finished unexpectedly, it is re-added to the queue setting the BuildState to 'UNEXPECTED_FINISH'. How can I listen on this event and get the next build that is added to the queue?

1 comment
Comment actions Permalink

Hi Deniz,

at this time there is no simple way to detect such an event, please watch/vote for http://youtrack.jetbrains.com/issue/TW-30394.

You can detect builds re-added to the queue using following code:

  public class Listener extends BuildServerAdapter {
    @Override
    public void buildTypeAddedToQueue(@NotNull final SQueuedBuild queuedBuild) {
      TriggeredBy by = queuedBuild.getTriggeredBy();
      String reAdded = by.getParameters().get("unexpectedFinishCounter");
      if (reAdded != null) {
        //build was re-added after unexpected finish
      }
    }
  }


Hope it helps.
0

Please sign in to leave a comment.