I tried it myself recently with little success. This seems to be the problem. According to the documentation for the FileParameterValue class, there is a constructor that accepts java.io.File like this:
@DataBoundConstructor FileParameterValue(String name, org.apache.commons.fileupload.FileItem file)
There is another one waiting for a FileItem , for example:
FileParameterValue(String name, File file, String originalFileName)
But since only the first is annotated using @DataBoundConstructor , even when I try to use the latter in a script:
file = new File(pwd(), 'test.txt'); build( job: 'jobB', parameters: [ [$class: "FileParameterValue", name: "TEST_FILE", file: file, originalFileName: 'test.txt'] ] )
Note that this requires a script statement to instantiate java.io.File
... I get the following error:
java.lang.ClassCastException: hudson.model.FileParameterValue.file expects interface org.apache.commons.fileupload.FileItem but received class java.io.File
I understand that only a file uploaded by the user as an interactive login at runtime provides an object of type org.apache.commons.fileupload.FileItem , so in the end I resorted to archiving the file in the first task and unarchiving in the transition work and solve the problem . Of course, this is not ideal, but if you are in traffic, this is the fastest way to figure it out.
Mig82 source share