Skip to content
Permalink
Browse files

[FIXED JENKINS-21225]

  • Loading branch information...
ninian committed Mar 2, 2015
1 parent c0d1e56 commit 68c4a9704b8a9ce4ea630a9bee605ea8638f69fb
12 pom.xml
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>email-ext</artifactId>
<version>2.29</version>
<version>2.37</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -97,6 +97,16 @@
<version>2.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>config-file-provider</artifactId>
<version>2.7.4</version>
</dependency>
</dependencies>

<scm>
@@ -7,14 +7,12 @@
import hudson.plugins.emailext.EmailType;
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.plugins.emailext.plugins.EmailTrigger;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.trigger.FailureTrigger;
import hudson.tasks.Publisher;
import hudson.util.DescribableList;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.commons.lang.StringUtils;
@@ -44,7 +42,7 @@ public ExtEmailSliceSpec() {
}

@Override
protected ProjectHandler getProjectHandler(AbstractProject project) {
protected ProjectHandler getProjectHandler(AbstractProject<?,?> project) {
return this;
}
@Override
@@ -53,21 +51,21 @@ protected ProjectHandler getProjectHandler(AbstractProject project) {
values.add("$DEFAULT_RECIPIENTS");
return values;
}
public String getRecipients(AbstractProject project) {
public String getRecipients(AbstractProject<?,?> project) {
ExtendedEmailPublisher mailer = getMailer(project);
if (mailer != null) {
return mailer.recipientList;
} else {
return null;
}
}
private ExtendedEmailPublisher getMailer(AbstractProject project) {
private ExtendedEmailPublisher getMailer(AbstractProject<?,?> project) {
DescribableList<Publisher,Descriptor<Publisher>> publishers = project.getPublishersList();
Descriptor<Publisher> descriptor = Hudson.getInstance().getDescriptor(ExtendedEmailPublisher.class);
Publisher emailPublisher = publishers.get(descriptor);
return (ExtendedEmailPublisher) emailPublisher;
}
public boolean setRecipients(AbstractProject project, String value) {
public boolean setRecipients(AbstractProject<?,?> project, String value) {
ExtendedEmailPublisher mailer = getMailer(project);
if (!StringUtils.equals(value, mailer.recipientList)) {
mailer.recipientList = value;
@@ -76,12 +74,12 @@ public boolean setRecipients(AbstractProject project, String value) {
return false;
}
}
public boolean addMailer(AbstractProject project) throws IOException {
public boolean addMailer(AbstractProject<?,?> project) throws IOException {
ExtendedEmailPublisher mailer = getMailer(project);
if (mailer == null) {
DescribableList<Publisher,Descriptor<Publisher>> publishers = project.getPublishersList();
ExtendedEmailPublisher publisher = new ExtendedEmailPublisher();
FailureTrigger trigger = new FailureTrigger();
FailureTrigger trigger = FailureTrigger.createDefault();
EmailType email = new EmailType();
email.setSendToDevelopers(true);
email.setSendToRecipientList(true);
@@ -98,7 +96,7 @@ public boolean addMailer(AbstractProject project) throws IOException {
return false;
}
}
public boolean removeMailer(AbstractProject project) throws IOException {
public boolean removeMailer(AbstractProject<?,?> project) throws IOException {
ExtendedEmailPublisher mailer = getMailer(project);
if (mailer != null) {
DescribableList<Publisher,Descriptor<Publisher>> publishers = project.getPublishersList();
@@ -112,7 +110,7 @@ public boolean removeMailer(AbstractProject project) throws IOException {
/**
* not yet implemented for ExtendedEmailPublisher
*/
public boolean sendToIndividuals(AbstractProject project) {
public boolean sendToIndividuals(AbstractProject<?,?> project) {
boolean result = false;
ExtendedEmailPublisher mailer = getMailer(project);
if (mailer != null) {
@@ -4,12 +4,11 @@

import hudson.model.AbstractProject;

@SuppressWarnings("unchecked")
public interface ProjectHandler {

String getRecipients(AbstractProject project);
boolean removeMailer(AbstractProject project) throws IOException;
boolean addMailer(AbstractProject project) throws IOException;
boolean setRecipients(AbstractProject project, String recipients) throws IOException;
boolean sendToIndividuals(AbstractProject project);
String getRecipients(AbstractProject<?,?> project);
boolean removeMailer(AbstractProject<?,?> project) throws IOException;
boolean addMailer(AbstractProject<?,?> project) throws IOException;
boolean setRecipients(AbstractProject<?,?> project, String recipients) throws IOException;
boolean sendToIndividuals(AbstractProject<?,?> project);
}
@@ -73,14 +73,14 @@ private void doTestSetValues(String expected, String valuesString) throws Except
doTestSetValues(expected, valuesString, false, false);
doTestSetValues(expected, valuesString, true, false);
}
@SuppressWarnings("unchecked")

private void doTestSetValues(String expected, String valuesString, boolean maven, boolean core) throws Exception {

if (!core) {
expected = expected.replaceAll(" ", ",");
}

AbstractProject project;
AbstractProject<?,?> project;
if (maven) {
project = createMavenProject();
} else {
@@ -102,9 +102,9 @@ private void doTestSetValues(String expected, String valuesString, boolean maven

assertEquals(expected, got);
}
@SuppressWarnings("unchecked")

public void testCommonValues() {
UnorderedStringSlice slice = new UnorderedStringSlice(new ExtEmailSlicer.ExtEmailSliceSpec());
UnorderedStringSlice<AbstractProject<?,?>> slice = new UnorderedStringSlice<AbstractProject<?,?>>(new ExtEmailSlicer.ExtEmailSliceSpec());
List<String> values = slice.getConfiguredValues();
assertEquals(3, values.size());
assertTrue(values.contains(""));
@@ -164,7 +164,7 @@ private MavenModuleSet createMavenProjectWithSendToIndividualsAndEmptyRecipients
FreeStyleProject project = createFreeStyleProject();
DescribableList<Publisher,Descriptor<Publisher>> publishers = project.getPublishersList();
ExtendedEmailPublisher publisher = new ExtendedEmailPublisher();
FailureTrigger trigger = new FailureTrigger();
FailureTrigger trigger = FailureTrigger.createDefault();
EmailType email = new EmailType();
email.setSendToDevelopers(true);
email.setSendToRecipientList(true);

0 comments on commit 68c4a97

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