Skip to content

Commit

Permalink
JENKINS-11914: new expandAll method doesn't work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
aheritier committed Nov 29, 2011
1 parent c739f28 commit 03ee100
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/jenkinsci/plugins/tokenmacro/TokenMacro.java
Expand Up @@ -23,22 +23,20 @@
*/
package org.jenkinsci.plugins.tokenmacro;

import com.google.common.collect.ListMultimap;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.Util;
import hudson.model.TaskListener;
import hudson.model.AbstractBuild;
import hudson.model.Hudson;
import hudson.model.TaskListener;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;

import com.google.common.collect.ListMultimap;

/**
* A macro that expands to text values in the context of a {@link AbstractBuild}.
*
Expand Down Expand Up @@ -184,12 +182,14 @@ public static String expand(AbstractBuild<?,?> context, TaskListener listener, S
* String that contains macro references in it, like "foo bar ${zot}".
*/
public static String expandAll(AbstractBuild<?,?> context, TaskListener listener, String stringWithMacro) throws MacroEvaluationException, IOException, InterruptedException {
String s = expand(context,listener,stringWithMacro);
if (s==null || s.length()==0) return s;

s = context.getEnvironment(listener).expand(s);
// Do nothing for an empty String
if (stringWithMacro==null || stringWithMacro.length()==0) return stringWithMacro;
// Expand environment variables
String s = context.getEnvironment(listener).expand(stringWithMacro);
// Expand build variables
s = Util.replaceMacro(s,context.getBuildVariableResolver());

// Expand Macros
s = expand(context,listener,s);
return s;
}
}

0 comments on commit 03ee100

Please sign in to comment.