Skip to content
Permalink
Browse files

[Fix JENKINS-35367] Pipeline templates (#140)

new token macro version with pipeline support
  • Loading branch information
davidvanlaatum committed Sep 24, 2016
1 parent 76e2b95 commit 15346e064eebf1b870b01a956ff03f92655562c6
Showing with 455 additions and 468 deletions.
  1. +7 −2 pom.xml
  2. +9 −8 src/main/java/hudson/plugins/emailext/AttachmentUtils.java
  3. +6 −8 src/main/java/hudson/plugins/emailext/EmailExtTemplateAction.java
  4. +3 −3 src/main/java/hudson/plugins/emailext/EmailExtTemplateActionFactory.java
  5. +10 −11 src/main/java/hudson/plugins/emailext/EmailRecipientUtils.java
  6. +1 −1 src/main/java/hudson/plugins/emailext/EmailType.java
  7. +27 −31 src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
  8. +12 −11 src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
  9. +5 −6 src/main/java/hudson/plugins/emailext/GroovyScriptPath.java
  10. +8 −7 src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java
  11. +2 −3 src/main/java/hudson/plugins/emailext/plugins/CssInliner.java
  12. +4 −3 src/main/java/hudson/plugins/emailext/plugins/EmailToken.java
  13. +4 −5 src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java
  14. +1 −2 src/main/java/hudson/plugins/emailext/plugins/EmailTriggerDescriptor.java
  15. +6 −7 src/main/java/hudson/plugins/emailext/plugins/RecipientProvider.java
  16. +1 −2 src/main/java/hudson/plugins/emailext/plugins/ZipDataSource.java
  17. +15 −10 src/main/java/hudson/plugins/emailext/plugins/content/AbstractEvalContent.java
  18. +2 −2 src/main/java/hudson/plugins/emailext/plugins/content/FailedTestsContent.java
  19. +14 −10 src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java
  20. +15 −11 src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java
  21. +4 −4 src/main/java/hudson/plugins/emailext/plugins/content/ScriptContentBuildWrapper.java
  22. +4 −4 src/main/java/hudson/plugins/emailext/plugins/content/StaticAnalysisUtilities.java
  23. +8 −3 src/main/java/hudson/plugins/emailext/plugins/content/TemplateContent.java
  24. +2 −1 src/main/java/hudson/plugins/emailext/plugins/content/TestCountsContent.java
  25. +3 −4 src/main/java/hudson/plugins/emailext/plugins/content/TriggerNameContent.java
  26. +7 −7 src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java
  27. +5 −6 src/main/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProvider.java
  28. +9 −11 ...n/java/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProvider.java
  29. +9 −8 src/main/java/hudson/plugins/emailext/plugins/recipients/ListRecipientProvider.java
  30. +2 −3 src/main/java/hudson/plugins/emailext/plugins/recipients/RecipientProviderUtilities.java
  31. +4 −8 src/main/java/hudson/plugins/emailext/plugins/recipients/RequesterRecipientProvider.java
  32. +8 −8 src/main/java/hudson/plugins/emailext/plugins/recipients/UpstreamComitterRecipientProvider.java
  33. +3 −3 src/main/java/hudson/plugins/emailext/plugins/trigger/AbortedTrigger.java
  34. +0 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java
  35. +3 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/AlwaysTrigger.java
  36. +3 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/BuildingTrigger.java
  37. +4 −4 src/main/java/hudson/plugins/emailext/plugins/trigger/FailureTrigger.java
  38. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTrigger.java
  39. +2 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/FirstUnstableTrigger.java
  40. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/FixedTrigger.java
  41. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/FixedUnhealthyTrigger.java
  42. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/ImprovementTrigger.java
  43. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/NotBuiltTrigger.java
  44. +1 −0 src/main/java/hudson/plugins/emailext/plugins/trigger/NthFailureTrigger.java
  45. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildScriptTrigger.java
  46. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildTrigger.java
  47. +3 −3 src/main/java/hudson/plugins/emailext/plugins/trigger/RegressionTrigger.java
  48. +2 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/ScriptTrigger.java
  49. +2 −1 src/main/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTrigger.java
  50. +4 −4 src/main/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTrigger.java
  51. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/StillFailingTrigger.java
  52. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/StillUnstableTrigger.java
  53. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/SuccessTrigger.java
  54. +2 −2 src/main/java/hudson/plugins/emailext/plugins/trigger/UnstableTrigger.java
  55. +9 −12 src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java
  56. +3 −5 src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java
  57. +13 −14 src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java
  58. +6 −15 src/test/java/hudson/plugins/emailext/EmailExtStepTest.java
  59. +12 −7 src/test/java/hudson/plugins/emailext/EmailTypeTest.java
  60. +5 −4 src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java
  61. +13 −9 src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherMatrixTest.java
  62. +23 −23 src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
  63. +16 −10 src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java
  64. +2 −1 src/test/java/hudson/plugins/emailext/plugins/CssInlinerTest.java
  65. +5 −4 src/test/java/hudson/plugins/emailext/plugins/OnlyRegressionsTest.java
  66. +5 −2 src/test/java/hudson/plugins/emailext/plugins/ZipDataSourceTest.java
  67. +8 −8 src/test/java/hudson/plugins/emailext/plugins/content/FailedTestsContentTest.java
  68. +7 −10 src/test/java/hudson/plugins/emailext/plugins/content/JellyScriptContentTest.java
  69. +5 −17 src/test/java/hudson/plugins/emailext/plugins/content/ScriptContentTest.java
  70. +5 −3 src/test/java/hudson/plugins/emailext/plugins/content/TestCountsContentTest.java
  71. +7 −5 src/test/java/hudson/plugins/emailext/plugins/content/TriggerNameContentTest.java
  72. +0 −2 src/test/java/hudson/plugins/emailext/plugins/recipients/DevelopersRecipientProviderTest.java
  73. +6 −7 ...est/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProviderTest.java
  74. +6 −7 ...va/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProviderTest.java
  75. +14 −15 src/test/java/hudson/plugins/emailext/plugins/recipients/MockUtilities.java
  76. +9 −13 src/test/java/hudson/plugins/emailext/plugins/recipients/TestUtilities.java
  77. +1 −2 src/test/java/hudson/plugins/emailext/plugins/trigger/BuildingTriggerTest.java
  78. +1 −5 src/test/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTriggerTest.java
  79. +1 −2 src/test/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTriggerTest.java
  80. +1 −2 src/test/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTriggerTest.java
  81. +0 −2 src/test/java/hudson/plugins/emailext/plugins/trigger/XNthFailureTriggerTest.java
  82. +6 −8 src/test/java/hudson/plugins/emailext/recipients/EmailRecipientUtilsTest.java
@@ -114,6 +114,12 @@
<artifactId>analysis-core</artifactId>
<version>1.54</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -124,7 +130,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<version>1.12.1</version>
<version>2.0</version>
</dependency>

<!-- workflow stuff -->
@@ -216,7 +222,6 @@
<scope>test</scope>
</dependency>


<!-- static analysys -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -9,6 +9,15 @@
import hudson.model.Run;
import hudson.plugins.emailext.plugins.ContentBuilder;
import hudson.plugins.emailext.plugins.ZipDataSource;
import org.apache.commons.lang.StringUtils;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.MimetypesFileTypeMap;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeUtility;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -18,14 +27,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.MimetypesFileTypeMap;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.internet.MimeUtility;
import javax.mail.internet.MimeBodyPart;
import org.apache.commons.lang.StringUtils;

/**
* @author acearl
@@ -9,21 +9,19 @@
import hudson.plugins.emailext.plugins.content.ScriptContent;
import hudson.util.FormValidation;
import hudson.util.StreamTaskListener;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;

import jenkins.model.Jenkins;

import org.apache.commons.lang.StringUtils;
import org.jenkinsci.lib.configprovider.ConfigProvider;
import org.jenkinsci.lib.configprovider.model.Config;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.bind.JavaScriptMethod;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;

/**
*
* @author acearl
@@ -6,14 +6,14 @@

package hudson.plugins.emailext;

import java.util.Collection;
import java.util.Collections;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.TransientProjectActionFactory;

import java.util.Collection;
import java.util.Collections;

/**
*
* @author acearl
@@ -1,25 +1,24 @@
package hudson.plugins.emailext;

import java.io.UnsupportedEncodingException;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.logging.Logger;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;

import hudson.EnvVars;
import hudson.model.TaskListener;
import hudson.model.User;
import hudson.plugins.emailext.plugins.ContentBuilder;
import hudson.tasks.Mailer;
import hudson.util.FormValidation;
import java.util.StringTokenizer;
import java.util.logging.Level;
import javax.mail.MessagingException;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import java.io.UnsupportedEncodingException;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

public class EmailRecipientUtils {

private static final Logger LOGGER = Logger.getLogger(EmailRecipientUtils.class.getName());
@@ -1,11 +1,11 @@
package hudson.plugins.emailext;

import hudson.*;
import hudson.plugins.emailext.plugins.RecipientProvider;
import hudson.plugins.emailext.plugins.recipients.CulpritsRecipientProvider;
import hudson.plugins.emailext.plugins.recipients.DevelopersRecipientProvider;
import hudson.plugins.emailext.plugins.recipients.ListRecipientProvider;
import hudson.plugins.emailext.plugins.recipients.RequesterRecipientProvider;

import java.util.ArrayList;
import java.util.List;

@@ -1,5 +1,8 @@
package hudson.plugins.emailext;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
@@ -8,15 +11,15 @@
import hudson.Launcher;
import hudson.matrix.MatrixAggregatable;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixRun;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.model.Result;
import hudson.model.TaskListener;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.User;
import hudson.plugins.emailext.plugins.ContentBuilder;
import hudson.plugins.emailext.plugins.CssInliner;
@@ -30,7 +33,27 @@
import hudson.tasks.MailMessageIdAction;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -47,33 +70,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import jenkins.model.Jenkins;

import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;

/**
* {@link Publisher} that sends notification e-mail.
*/
@@ -10,24 +10,25 @@
import hudson.tasks.Publisher;
import hudson.util.FormValidation;
import hudson.util.Secret;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
* These settings are global configurations
*/
@@ -1,14 +1,13 @@
package hudson.plugins.emailext;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

/**
* Model a classpath entry for Groovy pre script execution.
@@ -7,18 +7,19 @@
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.plugins.emailext.ExtendedEmailPublisherContext;
import hudson.tasks.Publisher;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import jenkins.model.Jenkins;
import net.java.sezpoz.Index;
import net.java.sezpoz.IndexItem;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;

/**
* {@link Publisher} that sends notification e-mail.
*
@@ -75,8 +76,8 @@ public static String transformText(String origText, ExtendedEmailPublisherContex
List<TokenMacro> macros = new ArrayList<>(getPrivateMacros());
if(additionalMacros != null)
macros.addAll(additionalMacros);
if(context.getBuild() != null) {
newText = TokenMacro.expandAll(context.getBuild(), context.getListener(), newText, false, macros);
if(context.getRun() != null) {
newText = TokenMacro.expandAll(context.getRun(), context.getWorkspace(), context.getListener(), newText, false, macros);
} else {
context.getListener().getLogger().println("Job type does not allow token replacement.");
}
@@ -1,7 +1,9 @@
package hudson.plugins.emailext.plugins;

import net.htmlparser.jericho.Source;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -15,9 +17,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import net.htmlparser.jericho.Source;
import org.apache.commons.lang.StringEscapeUtils;

/**
* <p>
* Inlines CSS to avoid the dreaded GMail Grimace.</p>
@@ -1,18 +1,19 @@
package hudson.plugins.emailext.plugins;

import net.java.sezpoz.Indexable;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import net.java.sezpoz.Indexable;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;

@Indexable(type=TokenMacro.class)
@Retention(SOURCE)
@Target({TYPE})
@Documented
public @interface EmailToken {
/* we don't need anything in here, just the annotation itself */
}
}

0 comments on commit 15346e0

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