+ * The file will be then placed into the workspace at the beginning of a build.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class FileParameterDefinition extends ParameterDefinition {
+ @DataBoundConstructor
+ public FileParameterDefinition(String name) {
+ super(name);
+ }
+
+ public ParameterDescriptor getDescriptor() {
+ return DESCRIPTOR;
+ }
+
+ public FileParameterValue createValue(StaplerRequest req, JSONObject jo) {
+ FileParameterValue p = req.bindJSON(FileParameterValue.class, jo);
+ p.setLocation(getName());
+ return p;
+ }
+
+ public static final ParameterDescriptor DESCRIPTOR = new DescriptorImpl();
+
+ public static class DescriptorImpl extends ParameterDescriptor {
+
+ protected DescriptorImpl() {
+ super(FileParameterDefinition.class);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "File Parameter";
+ }
+
+ @Override
+ public String getHelpFile() {
+ return "/help/parameter/file.html";
+ }
+ }
+}
diff --git a/core/src/main/java/hudson/model/FileParameterValue.java b/core/src/main/java/hudson/model/FileParameterValue.java
new file mode 100644
index 0000000000..460a95768b
--- /dev/null
+++ b/core/src/main/java/hudson/model/FileParameterValue.java
@@ -0,0 +1,53 @@
+package hudson.model;
+
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+import hudson.tasks.BuildWrapper;
+import hudson.Launcher;
+
+import java.io.IOException;
+
+/**
+ * {@link ParameterValue} for {@link FileParameterDefinition}.
+ *
+ *
Persistence
+ *
+ * {@link DiskFileItem} is persistable via serialization,
+ * (although the data may get very large in XML) so this object
+ * as a whole is persistable.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class FileParameterValue extends ParameterValue {
+ private FileItem file;
+
+ private String location;
+
+ @DataBoundConstructor
+ public FileParameterValue(String name, FileItem file) {
+ super(name);
+ assert file!=null;
+ this.file = file;
+ }
+
+ // post initialization hook
+ /*package*/ void setLocation(String location) {
+ this.location = location;
+ }
+
+ public BuildWrapper createBuildWrapper(AbstractBuild,?> build) {
+ return new BuildWrapper() {
+ public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
+ listener.getLogger().println("Copying file to "+location);
+ build.getProject().getWorkspace().child(location).copyFrom(file);
+ file = null;
+ return new Environment() {};
+ }
+
+ public Descriptor getDescriptor() {
+ return null;
+ }
+ };
+ }
+}
diff --git a/core/src/main/java/hudson/model/ParameterValue.java b/core/src/main/java/hudson/model/ParameterValue.java
index a87c76e47a..06dec8f6a7 100644
--- a/core/src/main/java/hudson/model/ParameterValue.java
+++ b/core/src/main/java/hudson/model/ParameterValue.java
@@ -113,4 +113,17 @@ public abstract class ParameterValue {
public VariableResolver createVariableResolver(AbstractBuild,?> build) {
return VariableResolver.NONE;
}
+
+ /**
+ * Accessing {@link ParameterDefinition} is not a good idea.
+ *
+ * @deprecated
+ * parameter definition may change any time. So if you find yourself
+ * in need of accessing the information from {@link ParameterDefinition},
+ * instead copy them in {@link ParameterDefinition#createValue(StaplerRequest, JSONObject)}
+ * into {@link ParameterValue}.
+ */
+ public ParameterDefinition getDefinition() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/core/src/main/java/hudson/model/ParameterizedProjectTask.java b/core/src/main/java/hudson/model/ParameterizedProjectTask.java
index a9c2bd504b..9f3a231487 100644
--- a/core/src/main/java/hudson/model/ParameterizedProjectTask.java
+++ b/core/src/main/java/hudson/model/ParameterizedProjectTask.java
@@ -12,11 +12,10 @@ import java.util.List;
*/
public class ParameterizedProjectTask extends QueueTaskFilter {
- private final AbstractProject, ?> project;
+ private final AbstractProject,?> project;
private final List parameters;
- public ParameterizedProjectTask(AbstractProject, ?> project,
- List parameters) {
+ public ParameterizedProjectTask(AbstractProject,?> project, List parameters) {
super(project);
this.project = project;
this.parameters = parameters;
diff --git a/core/src/main/java/hudson/model/ParametersDefinitionProperty.java b/core/src/main/java/hudson/model/ParametersDefinitionProperty.java
index 26562a768e..bc6d45cf2e 100644
--- a/core/src/main/java/hudson/model/ParametersDefinitionProperty.java
+++ b/core/src/main/java/hudson/model/ParametersDefinitionProperty.java
@@ -148,5 +148,6 @@ public class ParametersDefinitionProperty extends JobProperty
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/main/resources/hudson/model/FileParameterDefinition/index.jelly b/core/src/main/resources/hudson/model/FileParameterDefinition/index.jelly
new file mode 100644
index 0000000000..4cf936d537
--- /dev/null
+++ b/core/src/main/resources/hudson/model/FileParameterDefinition/index.jelly
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/main/resources/hudson/model/FileParameterValue/value.jelly b/core/src/main/resources/hudson/model/FileParameterValue/value.jelly
new file mode 100644
index 0000000000..f03140b601
--- /dev/null
+++ b/core/src/main/resources/hudson/model/FileParameterValue/value.jelly
@@ -0,0 +1,7 @@
+
+
+ TODO
+
+
\ No newline at end of file
diff --git a/core/src/main/resources/hudson/model/StringParameterDefinition/config.jelly b/core/src/main/resources/hudson/model/StringParameterDefinition/config.jelly
index 35d06e8816..855a67d0e6 100644
--- a/core/src/main/resources/hudson/model/StringParameterDefinition/config.jelly
+++ b/core/src/main/resources/hudson/model/StringParameterDefinition/config.jelly
@@ -4,10 +4,7 @@
-
+
-
-
-
\ No newline at end of file
diff --git a/war/resources/help/parameter/file-name.html b/war/resources/help/parameter/file-name.html
new file mode 100644
index 0000000000..4657f84019
--- /dev/null
+++ b/war/resources/help/parameter/file-name.html
@@ -0,0 +1,4 @@
+
+ Specifies the location, relative in the workspace, where the uploaded file will be placed
+ (for example, like "jaxb-ri/data.zip")
+
\ No newline at end of file
diff --git a/war/resources/help/parameter/file.html b/war/resources/help/parameter/file.html
new file mode 100644
index 0000000000..d2ecc0790e
--- /dev/null
+++ b/war/resources/help/parameter/file.html
@@ -0,0 +1,14 @@
+
+ Accepts a file submission from a browser as a build parameter.
+ The uploaded file will be placed at the specified location in the workspace,
+ which your build can then access and use.
+
+
+ This is useful for many situations, such as:
+
+
+
Letting people run tests on the artifacts they built.
+
Automating the upload/release/deployment process by allowing the user to place the file.
+
Perform data processing by uploading a dataset.
+
+
\ No newline at end of file
diff --git a/war/resources/help/parameter/string-default.html b/war/resources/help/parameter/string-default.html
new file mode 100644
index 0000000000..b150947b1e
--- /dev/null
+++ b/war/resources/help/parameter/string-default.html
@@ -0,0 +1,3 @@
+
+ Specifies the default value of the field, which allows the user to save typing the actual value.
+
\ No newline at end of file
diff --git a/war/resources/help/parameter/string.html b/war/resources/help/parameter/string.html
new file mode 100644
index 0000000000..2dc8574d1d
--- /dev/null
+++ b/war/resources/help/parameter/string.html
@@ -0,0 +1,10 @@
+
+ Defines a simple text parameter, where users can enter a string value,
+ which you can use during a build, either as an environment variable, or
+ through variable substitution in some other parts of the configuration.
+
+
+ Note that when this field is exposed as an environment variable, it
+ will be always in the upper case (e.g., the parameter "foo" would be exposed
+ as "FOO".)
+