/
RegressionTrigger.java
60 lines (47 loc) · 2.15 KB
/
RegressionTrigger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package hudson.plugins.emailext.plugins.trigger;
import hudson.Extension;
import hudson.model.Result;
import hudson.model.AbstractBuild;
import hudson.model.TaskListener;
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
public class RegressionTrigger extends EmailTrigger {
public static final String TRIGGER_NAME = "Regression";
@DataBoundConstructor
public RegressionTrigger(boolean sendToList, boolean sendToDevs, boolean sendToRequestor, boolean sendToCulprits, String recipientList,
String replyTo, String subject, String body, String attachmentsPattern, int attachBuildLog, String contentType) {
super(sendToList, sendToDevs, sendToRequestor, sendToCulprits, recipientList, replyTo, subject, body, attachmentsPattern, attachBuildLog, contentType);
}
@Override
public boolean trigger(AbstractBuild<?, ?> build, TaskListener listener) {
AbstractBuild<?,?> previousBuild = ExtendedEmailPublisher.getPreviousBuild(build, listener);
if (previousBuild == null)
return build.getResult() == Result.FAILURE;
if (build.getTestResultAction() == null) return false;
if (previousBuild.getTestResultAction() == null)
return build.getTestResultAction().getFailCount() > 0;
return build.getTestResultAction().getFailCount() >
previousBuild.getTestResultAction().getFailCount();
}
@Extension
public static final class DescriptorImpl extends EmailTriggerDescriptor {
public DescriptorImpl() {
addTriggerNameToReplace(UnstableTrigger.TRIGGER_NAME);
addTriggerNameToReplace(StillUnstableTrigger.TRIGGER_NAME);
}
@Override
public String getDisplayName() {
return TRIGGER_NAME;
}
@Override
public boolean getDefaultSendToDevs() {
return true;
}
@Override
public boolean getDefaultSendToList() {
return true;
}
}
}