Skip to content

Commit

Permalink
[FIXED JENKINS-10108] File parameter didn't work correctly with matrix
Browse files Browse the repository at this point in the history
projects.
  • Loading branch information
kohsuke committed Jun 29, 2011
1 parent ec004a1 commit 47bc6d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -64,6 +64,9 @@
<li class=bug>
Fixed the redundant/incorrect encoding handling in XML configuration files.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-4525">issue 4525</a>)
<li class=bug>
File parameter didn't work correctly with matrix projects
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10108">issue 10108</a>)
<li class=rfe>
Groovy script console is now syntax highlighted.
<li class=rfe>
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/hudson/model/FileParameterValue.java
Expand Up @@ -57,7 +57,7 @@
* @author Kohsuke Kawaguchi
*/
public class FileParameterValue extends ParameterValue {
private FileItem file;
private final FileItem file;

/**
* The name of the originally uploaded file.
Expand Down Expand Up @@ -107,7 +107,6 @@ public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener l
FilePath locationFilePath = build.getWorkspace().child(location);
locationFilePath.getParent().mkdirs();
locationFilePath.copyFrom(file);
file = null;
locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build)));
}
return new Environment() {};
Expand Down
28 changes: 27 additions & 1 deletion test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc.
* Copyright (c) 2004-2011, Sun Microsystems, Inc., CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -48,6 +48,11 @@ import java.util.concurrent.TimeoutException
import hudson.model.JDK
import hudson.model.Slave
import hudson.Functions
import hudson.model.ParametersDefinitionProperty
import hudson.model.FileParameterDefinition
import hudson.model.Cause.LegacyCodeCause
import hudson.model.ParametersAction
import hudson.model.FileParameterValue

/**
*
Expand Down Expand Up @@ -290,4 +295,25 @@ public class MatrixProjectTest extends HudsonTestCase {
LabelAxis a = p.axes.find("label");
assertEquals(a.values as Set,names as Set);
}

@Bug(10108)
void testTwoFileParams() {
def p = createMatrixProject();
p.axes = new AxisList(new TextAxis("foo","1","2","3","4"));
p.addProperty(new ParametersDefinitionProperty(
new FileParameterDefinition("a.txt",""),
new FileParameterDefinition("b.txt",""),
));

def dir = createTmpDir()
def f = p.scheduleBuild2(0,new LegacyCodeCause(),new ParametersAction(
["aaa","bbb"].collect { it ->
def v = new FileParameterValue(it+".txt",File.createTempFile(it,"", dir),it)
v.setLocation(it)
return v;
}
))

assertBuildStatusSuccess(f.get(10,TimeUnit.SECONDS));
}
}

0 comments on commit 47bc6d3

Please sign in to comment.