@Override
  public boolean trigger(AbstractBuild<?, ?> build, TaskListener listener) {
    AbstractBuild<?, ?> previousBuild = ExtendedEmailPublisher.getPreviousBuild(build, listener);
    if (previousBuild == null) return build.getResult() == Result.FAILURE;

    if (build.getAction(AbstractTestResultAction.class) == null) return false;

    // if previous run didn't have test results and this one does (with failures)
    if (previousBuild.getAction(AbstractTestResultAction.class) == null)
      return build.getAction(AbstractTestResultAction.class).getFailCount() > 0;

    // if more tests failed during this run
    if (build.getAction(AbstractTestResultAction.class).getFailCount()
        > previousBuild.getAction(AbstractTestResultAction.class).getFailCount()) return true;

    // if any test failed this time, but not last time
    for (Object result : build.getAction(AbstractTestResultAction.class).getFailedTests()) {
      CaseResult res = (CaseResult) result;
      if (res.getAge() == 1) return true;
    }

    return false;
  }
Пример #2
0
 public int compare(CaseResult lhs, CaseResult rhs) {
   return lhs.getAge() - rhs.getAge();
 }