Skip to content
Permalink
Browse files

Merge branch 'JENKINS-27856'

  • Loading branch information...
slide committed Apr 10, 2015
2 parents ef770bc + 6493856 commit 77e69ea8258e82f5634f84c58c56d0b797717dc7
Showing with 190 additions and 20 deletions.
  1. +32 −0 src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
  2. +16 −2 src/main/java/hudson/plugins/emailext/plugins/EmailTriggerDescriptor.java
  3. +6 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/AbortedTrigger.java
  4. +0 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java
  5. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/AlwaysTrigger.java
  6. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/BuildingTrigger.java
  7. +15 −11 src/main/java/hudson/plugins/emailext/plugins/trigger/FailureTrigger.java
  8. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTrigger.java
  9. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/FirstUnstableTrigger.java
  10. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/FixedTrigger.java
  11. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/FixedUnhealthyTrigger.java
  12. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/ImprovementTrigger.java
  13. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/NotBuiltTrigger.java
  14. +6 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildScriptTrigger.java
  15. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildTrigger.java
  16. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/RegressionTrigger.java
  17. +7 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/ScriptTrigger.java
  18. +6 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTrigger.java
  19. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTrigger.java
  20. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/StillFailingTrigger.java
  21. +6 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/StillUnstableTrigger.java
  22. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/SuccessTrigger.java
  23. +5 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/UnstableTrigger.java
  24. +11 −2 src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.groovy
  25. +9 −1 src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.groovy
  26. +6 −0 src/main/webapp/help/globalConfig/defaultTriggers.html
@@ -3,6 +3,8 @@
import hudson.Extension;
import hudson.matrix.MatrixProject;
import hudson.model.AbstractProject;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.trigger.FailureTrigger;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Mailer;
import hudson.tasks.Publisher;
@@ -98,6 +100,8 @@
private String defaultPresendScript = "";

private List<GroovyScriptPath> defaultClasspath = new ArrayList<GroovyScriptPath>();

private List<EmailTriggerDescriptor> defaultTriggers = new ArrayList<EmailTriggerDescriptor>();

/**
* This is the global emergency email address
@@ -325,6 +329,13 @@ public String getDefaultPresendScript() {
public List<GroovyScriptPath> getDefaultClasspath() {
return defaultClasspath;
}

public List<EmailTriggerDescriptor> getDefaultTriggers() {
if(defaultTriggers.isEmpty()) {
defaultTriggers.add((EmailTriggerDescriptor)Jenkins.getInstance().getDescriptor(FailureTrigger.class));
}
return defaultTriggers;
}

public ExtendedEmailPublisherDescriptor() {
super(ExtendedEmailPublisher.class);
@@ -405,6 +416,27 @@ public boolean configure(StaplerRequest req, JSONObject formData)
listId = null;
}

List<String> classes = new ArrayList<String>();
if(formData.optJSONArray("defaultTriggers") != null) {
for(Object tName : formData.getJSONArray("defaultTriggers")) {
String triggerName = tName.toString();
classes.add(triggerName);
}
} else if(StringUtils.isNotEmpty(formData.optString("defaultTriggers"))) {
String triggerName = formData.getString("defaultTriggers");
classes.add(triggerName);
}

if(!classes.isEmpty()) {
defaultTriggers.clear();
for(String triggerName : classes) {
EmailTriggerDescriptor d = (EmailTriggerDescriptor)Jenkins.getInstance().getDescriptorByName(triggerName);
if(d != null) {
defaultTriggers.add(d);
}
}
}

save();
return super.configure(req, formData);
}
@@ -1,6 +1,8 @@
package hudson.plugins.emailext.plugins;

import hudson.model.Descriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import java.util.ArrayList;
import java.util.List;
@@ -35,6 +37,19 @@ public void addDefaultRecipientProvider(RecipientProvider provider) {
public List<RecipientProvider> getDefaultRecipientProviders() {
return defaultRecipientProviders;
}

public abstract EmailTrigger createDefault();

protected EmailTrigger _createDefault() {
EmailTrigger trigger;
try {
Constructor ctor = clazz.getConstructor(List.class, String.class, String.class, String.class, String.class, String.class, int.class, String.class);
trigger = (EmailTrigger)ctor.newInstance(defaultRecipientProviders, "", "$PROJECT_DEFAULT_REPLYTO", "$PROJECT_DEFAULT_SUBJECT", "$PROJECT_DEFAULT_CONTENT", "", 0, "project");
} catch(Exception e) {
trigger = null;
}
return trigger;
}

public boolean isWatchable() { return true; }

@@ -57,5 +72,4 @@ public boolean getDefaultSendToList() {
public boolean getDefaultSendToRequester() {
return false;
}

}
}
@@ -44,6 +44,11 @@ public DescriptorImpl() {
@Override
public String getDisplayName() {
return TRIGGER_NAME;
}
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -18,7 +18,6 @@
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.kohsuke.groovy.sandbox.SandboxTransformer;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

public abstract class AbstractScriptTrigger extends EmailTrigger {
@@ -46,6 +46,11 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}

@@ -54,5 +54,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -2,14 +2,13 @@

import hudson.Extension;
import hudson.model.AbstractBuild;
import jenkins.model.Jenkins;
import hudson.model.Result;
import hudson.model.TaskListener;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.recipients.DevelopersRecipientProvider;
import hudson.plugins.emailext.plugins.RecipientProvider;
import hudson.plugins.emailext.plugins.recipients.ListRecipientProvider;
import java.util.Collections;
import java.util.List;

import org.kohsuke.stapler.DataBoundConstructor;
@@ -19,27 +18,27 @@

public static final String TRIGGER_NAME = "Failure - Any";

@Deprecated
public static FailureTrigger createDefault() {
return new FailureTrigger(Collections.<RecipientProvider>singletonList(new ListRecipientProvider()), "", "$PROJECT_DEFAULT_REPLYTO", "$PROJECT_DEFAULT_SUBJECT", "$PROJECT_DEFAULT_CONTENT", "", 0, "project");
DescriptorImpl descriptor = (DescriptorImpl)Jenkins.getInstance().getDescriptor(FailureTrigger.class);
return (FailureTrigger)descriptor.createDefault();
}

@DataBoundConstructor
public FailureTrigger(List<RecipientProvider> recipientProviders, String recipientList, String replyTo, String subject, String body, String attachmentsPattern, int attachBuildLog, String contentType) {
public FailureTrigger(List<RecipientProvider> recipientProviders, String recipientList, String replyTo, String subject, String body,
String attachmentsPattern, int attachBuildLog, String contentType) {
super(recipientProviders, recipientList, replyTo, subject, body, attachmentsPattern, attachBuildLog, contentType);
}

@Deprecated
public FailureTrigger(boolean sendToList, boolean sendToDevs, boolean sendToRequester, boolean sendToCulprits, String recipientList, String replyTo, String subject, String body, String attachmentsPattern, int attachBuildLog, String contentType) {
public FailureTrigger(boolean sendToList, boolean sendToDevs, boolean sendToRequester, boolean sendToCulprits, String recipientList,
String replyTo, String subject, String body, String attachmentsPattern, int attachBuildLog, String contentType) {
super(sendToList, sendToDevs, sendToRequester, sendToCulprits,recipientList, replyTo, subject, body, attachmentsPattern, attachBuildLog, contentType);
}

@Override
public boolean trigger(AbstractBuild<?, ?> build, TaskListener listener) {
Result buildResult = build.getResult();
if (buildResult == Result.FAILURE) {
return true;
}
return false;
return build.getResult() == Result.FAILURE;
}

@Extension
@@ -52,6 +51,11 @@ public DescriptorImpl() {
@Override
public String getDisplayName() {
return TRIGGER_NAME;
}
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -1,6 +1,7 @@
package hudson.plugins.emailext.plugins.trigger;

import hudson.Extension;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.RecipientProvider;
import java.util.List;

@@ -27,6 +28,10 @@ public FirstFailureTrigger(boolean sendToList, boolean sendToDevs, boolean sendT
public String getDisplayName() {
return TRIGGER_NAME;
}

public EmailTrigger createDefault() {
return _createDefault();
}
}

/**
@@ -54,5 +54,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -58,5 +58,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -72,5 +72,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -63,5 +63,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -44,5 +44,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -1,6 +1,7 @@
package hudson.plugins.emailext.plugins.trigger;

import hudson.Extension;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.RecipientProvider;
import java.util.List;
@@ -38,5 +39,10 @@ public String getDisplayName() {
public boolean isWatchable() {
return false;
}

@Override
public EmailTrigger createDefault() {
return new PreBuildScriptTrigger(defaultRecipientProviders, "", "$PROJECT_DEFAULT_REPLYTO", "$PROJECT_DEFAULT_SUBJECT", "$PROJECT_DEFAULT_CONTENT", "", 0, "project", "");
}
}
}
@@ -46,5 +46,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -74,5 +74,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -1,6 +1,7 @@
package hudson.plugins.emailext.plugins.trigger;

import hudson.Extension;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.RecipientProvider;
import hudson.plugins.emailext.plugins.recipients.ListRecipientProvider;
@@ -37,10 +38,15 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public boolean isWatchable() {
return false;
}

@Override
public EmailTrigger createDefault() {
return new ScriptTrigger(defaultRecipientProviders, "", "$PROJECT_DEFAULT_REPLYTO", "$PROJECT_DEFAULT_SUBJECT", "$PROJECT_DEFAULT_CONTENT", "", 0, "project", "");
}
}
}
@@ -1,6 +1,7 @@
package hudson.plugins.emailext.plugins.trigger;

import hudson.Extension;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.RecipientProvider;
import java.util.List;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -26,5 +27,10 @@ public SecondFailureTrigger(boolean sendToList, boolean sendToDevs, boolean send
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -56,5 +56,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -54,5 +54,10 @@ public DescriptorImpl() {
public String getDisplayName() {
return TRIGGER_NAME;
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}
@@ -55,6 +55,11 @@ public DescriptorImpl() {
@Override
public String getDisplayName() {
return TRIGGER_NAME;
}
}

@Override
public EmailTrigger createDefault() {
return _createDefault();
}
}
}

0 comments on commit 77e69ea

Please sign in to comment.
You can’t perform that action at this time.