Skip to content

Commit

Permalink
Merge pull request #1 from sullivac/master
Browse files Browse the repository at this point in the history
[FIXED JENKINS-26005] - Modify the constructor of RunConditionEmailTrigger to call the non-depre...
  • Loading branch information
oleg-nenashev committed Apr 29, 2015
2 parents 02c2f42 + 19588e6 commit 9ff4683
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -75,7 +88,7 @@ public boolean trigger(AbstractBuild<?, ?> ab, TaskListener tl) {
public RunCondition getCondition() {
return condition;
}

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

Expand All @@ -88,9 +101,9 @@ public static final class DescriptorImpl extends EmailTriggerDescriptor {
@Override
public String getDisplayName() {
return Messages.RunConditionEmailTrigger_displayName();
}
}
}

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

0 comments on commit 9ff4683

Please sign in to comment.