Skip to content
Permalink
Browse files

Modify the constructor of RunConditionEmailTrigger to call the non-de…

…precated constructor.

    The constructor that passes boolean parameters for the "Send To" list has been deprecated as 2.38 (email-ext.)
    Fix for JENKINS-26005.
  • Loading branch information
Corey Sullivan
Corey Sullivan committed Apr 16, 2015
1 parent 02c2f42 commit 19588e6e57c2950ec9559e550345e5d723d1355a
@@ -69,7 +69,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>email-ext</artifactId>
<version>2.34</version>
<version>2.38</version>
<type>jar</type>
<optional>true</optional>
</dependency>
@@ -29,9 +29,12 @@
import hudson.model.TaskListener;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.RecipientProvider;
import org.jenkins_ci.plugins.run_condition.RunCondition;
import org.kohsuke.stapler.DataBoundConstructor;

import java.util.List;

/**
* Allows to use run conditions in Extended Email Plugin.
* This trigger wraps a run condition expression.
@@ -40,19 +43,29 @@
*/
public class RunConditionEmailTrigger extends EmailTrigger {
RunCondition condition;

@DataBoundConstructor

/**
* Deprecated. This constructor is here for backwards compatibility, but it is deprecated in email-ext-2.38.
*/
@Deprecated
public RunConditionEmailTrigger(boolean sendToList, boolean sendToDevs, boolean sendToRequestor, boolean sendToCulprits, String recipientList,
String replyTo, String subject, String body, String attachmentsPattern, int attachBuildLog, String contentType, RunCondition condition) {
super(sendToList, sendToDevs, sendToRequestor, sendToCulprits, recipientList, replyTo, subject, body, attachmentsPattern, attachBuildLog, contentType);
this.condition = condition;
}


@DataBoundConstructor
public RunConditionEmailTrigger(List<RecipientProvider> recipientProviders, String recipientList, String replyTo, String subject,
String body, String attachmentsPattern, int attachBuildLog, String contentType, RunCondition condition){
super(recipientProviders, recipientList, replyTo, subject, body, attachmentsPattern, attachBuildLog, contentType);
this.condition = condition;
}

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

@Override
public boolean trigger(AbstractBuild<?, ?> ab, TaskListener tl) {
BuildListener listener;
@@ -63,7 +76,7 @@ public boolean trigger(AbstractBuild<?, ?> ab, TaskListener tl) {
logError(tl, Messages.RunConditionEmailTrigger_listenerClassConvError());
return false;
}

try {
return condition.runPerform(ab, listener);
} catch (Exception ex) {
@@ -75,7 +88,7 @@ public boolean trigger(AbstractBuild<?, ?> ab, TaskListener tl) {
public RunCondition getCondition() {
return condition;
}

@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

@@ -88,9 +101,9 @@ public EmailTriggerDescriptor getDescriptor() {
@Override
public String getDisplayName() {
return Messages.RunConditionEmailTrigger_displayName();
}
}
}

private void logError(TaskListener listener, String message) {
listener.error(Messages.logPrefix()+message);
}

0 comments on commit 19588e6

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