Source:
<code>public static String transformText(String origText, ExtendedEmailPublisherContext context, List<TokenMacro> additionalMacros) { if(StringUtils.isBlank(origText)) return ""; String defaultContent = Matcher.quoteReplacement(noNull(context.getPublisher().defaultContent)); String defaultSubject = Matcher.quoteReplacement(noNull(context.getPublisher().defaultSubject)); String defaultReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().replyTo)); String defaultBody = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultBody())); String defaultExtSubject = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultSubject())); String defaultRecipients = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultRecipients())); String defaultExtReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultReplyTo())); String defaultPresendScript = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultPresendScript())); String newText = origText.replaceAll( PROJECT_DEFAULT_BODY, defaultContent).replaceAll( PROJECT_DEFAULT_SUBJECT, defaultSubject).replaceAll( PROJECT_DEFAULT_REPLYTO, defaultReplyTo).replaceAll( DEFAULT_BODY, defaultBody).replaceAll( DEFAULT_SUBJECT, defaultExtSubject).replaceAll( DEFAULT_RECIPIENTS, defaultRecipients).replaceAll( DEFAULT_REPLYTO, defaultExtReplyTo).replaceAll( DEFAULT_PRESEND_SCRIPT, defaultPresendScript); try { List<TokenMacro> macros = new ArrayList<TokenMacro>(getPrivateMacros()); if(additionalMacros != null) macros.addAll(additionalMacros); <START> Run<?, ?> run = context.getBuild(); <END> if (run instanceof AbstractBuild) { newText = TokenMacro.expandAll((AbstractBuild<?, ?>) run, context.getListener(), newText, false, macros); } else { context.getListener().getLogger().println("Unable to transform email text. Not an impl of AbstractBuild."); } } catch (MacroEvaluationException e) { context.getListener().getLogger().println("Error evaluating token: " + e.getMessage()); } catch (Exception e) { Logger.getLogger(ContentBuilder.class.getName()).log(Level.SEVERE, null, e); } return newText; }</code><technical_language>If AbstractBuild, of macros get replaced. This is a big issue IMHO, of biggest features of email-ext</technical_language>

Target:
public static String transformText(String origText, ExtendedEmailPublisherContext context, List<TokenMacro> additionalMacros) { if(StringUtils.isBlank(origText)) return ""; String defaultContent = Matcher.quoteReplacement(noNull(context.getPublisher().defaultContent)); String defaultSubject = Matcher.quoteReplacement(noNull(context.getPublisher().defaultSubject)); String defaultReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().replyTo)); String defaultBody = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultBody())); String defaultExtSubject = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultSubject())); String defaultRecipients = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultRecipients())); String defaultExtReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultReplyTo())); String defaultPresendScript = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultPresendScript())); String newText = origText.replaceAll( PROJECT_DEFAULT_BODY, defaultContent).replaceAll( PROJECT_DEFAULT_SUBJECT, defaultSubject).replaceAll( PROJECT_DEFAULT_REPLYTO, defaultReplyTo).replaceAll( DEFAULT_BODY, defaultBody).replaceAll( DEFAULT_SUBJECT, defaultExtSubject).replaceAll( DEFAULT_RECIPIENTS, defaultRecipients).replaceAll( DEFAULT_REPLYTO, defaultExtReplyTo).replaceAll( DEFAULT_PRESEND_SCRIPT, defaultPresendScript); try { List<TokenMacro> macros = new ArrayList<TokenMacro>(getPrivateMacros()); if(additionalMacros != null) macros.addAll(additionalMacros); newText = TokenMacro.expandAll(context.getBuild(), context.getWorkspace(), context.getListener(), newText, false, macros); } catch (MacroEvaluationException e) { context.getListener().getLogger().println("Error evaluating token: " + e.getMessage()); } catch (Exception e) { Logger.getLogger(ContentBuilder.class.getName()).log(Level.SEVERE, null, e); } return newText; }