Package hudson.model
Class FileParameterValue
- java.lang.Object
-
- hudson.model.ParameterValue
-
- hudson.model.FileParameterValue
-
- All Implemented Interfaces:
Serializable
public class FileParameterValue extends ParameterValue
ParameterValue
forFileParameterDefinition
.Persistence
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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileParameterValue.FileItemImpl
Default implementation fromFile
.
-
Field Summary
Fields Modifier and Type Field Description static boolean
ALLOW_FOLDER_TRAVERSAL_OUTSIDE_WORKSPACE
Escape hatch for SECURITY-1074, fileParameter used to escape their expected folder.-
Fields inherited from class hudson.model.ParameterValue
name
-
-
Constructor Summary
Constructors Modifier Constructor Description FileParameterValue(String name, File file, String originalFileName)
FileParameterValue(String name, org.apache.commons.fileupload.FileItem file)
protected
FileParameterValue(String name, org.apache.commons.fileupload.FileItem file, String originalFileName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildEnvironment(Run<?,?> build, EnvVars env)
Exposes the originalFileName as an environment variable.BuildWrapper
createBuildWrapper(AbstractBuild<?,?> build)
Called at the beginning of a build (but afterSCM
operations have taken place) to let aParameterValue
contributes aBuildWrapper
to the build.VariableResolver<String>
createVariableResolver(AbstractBuild<?,?> build)
Returns aVariableResolver
so that other components likeBuilder
s can perform variable substitution to reflect parameter values into the build process.DirectoryBrowserSupport
doDynamic(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Serve this file parameter in response to aStaplerRequest
.boolean
equals(Object obj)
Compares file parameters (existing files will be considered as different).org.apache.commons.fileupload.FileItem
getFile()
String
getLocation()
String
getOriginalFileName()
Get the name of the originally uploaded file.String
getShortDescription()
Computes a human-readable possible-localized one-line description of the parameter value.Object
getValue()
Returns the most natural Java object that represents the actual value, like boolean, string, etc.int
hashCode()
protected void
setLocation(String location)
String
toString()
-
Methods inherited from class hudson.model.ParameterValue
buildEnvVars, buildEnvVars, getAssignedLabel, getDefinition, getDescription, getFormattedDescription, getName, isSensitive, setDescription
-
-
-
-
Field Detail
-
ALLOW_FOLDER_TRAVERSAL_OUTSIDE_WORKSPACE
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean ALLOW_FOLDER_TRAVERSAL_OUTSIDE_WORKSPACE
Escape hatch for SECURITY-1074, fileParameter used to escape their expected folder. It's not recommended to enable for security reasons. That option is only present for backward compatibility.
-
-
Constructor Detail
-
FileParameterValue
@DataBoundConstructor public FileParameterValue(String name, org.apache.commons.fileupload.FileItem file)
-
-
Method Detail
-
setLocation
protected void setLocation(String location)
-
getLocation
public String getLocation()
-
getValue
public Object getValue()
Description copied from class:ParameterValue
Returns the most natural Java object that represents the actual value, like boolean, string, etc.- Overrides:
getValue
in classParameterValue
- Returns:
- if there is no natural value for this parameter type,
this
may be used;null
may be used when the value is normally defined but missing in this case for various reasons
-
buildEnvironment
public void buildEnvironment(Run<?,?> build, EnvVars env)
Exposes the originalFileName as an environment variable.- Overrides:
buildEnvironment
in classParameterValue
- Parameters:
build
- The build for which this parameter is being used. Never null.env
- never null.
-
createVariableResolver
public VariableResolver<String> createVariableResolver(AbstractBuild<?,?> build)
Description copied from class:ParameterValue
Returns aVariableResolver
so that other components likeBuilder
s can perform variable substitution to reflect parameter values into the build process.This is yet another means in which a
ParameterValue
can influence a build.- Overrides:
createVariableResolver
in classParameterValue
- Parameters:
build
- The build for which this parameter is being used. Never null.- Returns:
- if the parameter value is not interested in participating to the
variable replacement process, return
VariableResolver.NONE
.
-
getOriginalFileName
public String getOriginalFileName()
Get the name of the originally uploaded file. If thisFileParameterValue
was created prior to 1.362, this method will returnnull
.- Returns:
- the name of the originally uploaded file
-
getFile
public org.apache.commons.fileupload.FileItem getFile()
-
createBuildWrapper
public BuildWrapper createBuildWrapper(AbstractBuild<?,?> build)
Description copied from class:ParameterValue
Called at the beginning of a build (but afterSCM
operations have taken place) to let aParameterValue
contributes aBuildWrapper
to the build.This provides a means for a parameter to perform more extensive set up / tear down during a build.
- Overrides:
createBuildWrapper
in classParameterValue
- Parameters:
build
- The build for which this parameter is being used. Never null.- Returns:
- null if the parameter has no
BuildWrapper
to contribute to.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classParameterValue
-
equals
public boolean equals(Object obj)
Compares file parameters (existing files will be considered as different).- Overrides:
equals
in classParameterValue
- Since:
- 1.586 Function has been modified in order to avoid JENKINS-19017 issue (wrong merge of builds in the queue).
-
getShortDescription
public String getShortDescription()
Description copied from class:ParameterValue
Computes a human-readable possible-localized one-line description of the parameter value.This message is used as a tooltip to describe jobs in the queue. The text should be one line without new line. No HTML allowed (the caller will perform necessary HTML escapes, so any text can be returned.)
- Overrides:
getShortDescription
in classParameterValue
-
doDynamic
public DirectoryBrowserSupport doDynamic(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Serve this file parameter in response to aStaplerRequest
.
-
-