Skip to content

Commit

Permalink
[FIXED JENKINS-28980] Do not rely on default ArtifactManager implemen…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
olivergondza committed Jun 19, 2015
1 parent a31d1de commit ed34853
Showing 1 changed file with 18 additions and 12 deletions.
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;

import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand All @@ -16,15 +17,17 @@
import hudson.model.Descriptor;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.Run;
import hudson.model.StringParameterValue;
import hudson.model.TaskListener;
import hudson.util.FormValidation;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

import javax.annotation.Nullable;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
Expand All @@ -37,6 +40,8 @@
import java.util.Properties;
import java.util.logging.Logger;

import jenkins.util.VirtualFile;

public class FileBuildParameters extends AbstractBuildParameters {
private static final Logger LOGGER = Logger.getLogger(FileBuildParameters.class.getName());

Expand Down Expand Up @@ -110,18 +115,20 @@ private List<ParameterValue> extractAllValues(AbstractBuild<?,?> build, TaskList
List<ParameterValue> values = new ArrayList<ParameterValue>();
EnvVars env = getEnvironment(build, listener);
for(String file:allFiles) {
FilePath f = null;
// First try to retrieve as a build artifact, so we don't need build workspace to be online
for (Run.Artifact artifact : build.getArtifacts()) {
if (artifact.relativePath.equals(file)) {
f = new FilePath(artifact.getFile());
break;
}
String s = null;
VirtualFile artifact = build.getArtifactManager().root().child(file);
if (artifact.isFile()) {
s = IOUtils.toString(artifact.open());
}
if (f == null) {
f = build.getWorkspace().child(file);

if (s == null) {
FilePath f = build.getWorkspace().child(file);
if (f.exists()) {
s = ParameterizedTriggerUtils.readFileToString(f, getEncoding());
}
}
if (!f.exists()) {

if (s == null) {
listener.getLogger().println(Plugin.LOG_TAG + " Properties file "
+ file + " did not exist.");
if (getFailTriggerOnMissing()) {
Expand All @@ -132,7 +139,6 @@ private List<ParameterValue> extractAllValues(AbstractBuild<?,?> build, TaskList
continue;
}

String s = ParameterizedTriggerUtils.readFileToString(f, getEncoding());
s = env.expand(s);
Properties p = ParameterizedTriggerUtils.loadProperties(s);

Expand Down

0 comments on commit ed34853

Please sign in to comment.