Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED JENKINS-26005] - Modify the constructor of RunConditionEmailTrigger to call the non-depre... #1

Merged
merged 1 commit into from Apr 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the future... Please avoid formatting changes in bugfixes

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