Per File Parameter 'help text' on Jenkins build,
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.
The name of the submitted file is available in the environment variable whose name is the same as file location. For example, if you set the file location to be abc.zip, then ${abc.zip} would give you the original file name passed from the browser (such as my.zip.) The name will not include the directory name portion.
File upload is optional. If a user chooses not to upload anything, Jenkins will simply skips this parameter and will not place anything (but it also will not delete anything that's already in the workspace.)
And 'File location'
Specifies the location, relative in the workspace, where the uploaded file will be placed (for example, like "jaxb-ri/data.zip")
Simple upload of zip file per example tried - doesn't seem to upload file anywhere - Neither in Workspace , nor under some temp directory. How to locate the file &/ make use of it?.
Here is simple pipeline for attempt on file upload..
properties(
[
parameters(
[ file(name: "file1", file: "file1.zip", description: 'Choose path to upload file1.zip from local system.') ]
)
]
)
node {
stage("Upload File") {
sh '''
ls -lrt
ls ${file1.zip} ${file1} file1.zip
'''
}
}
And respective error on run as observed in Console log.
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Upload File)
[Pipeline] sh
[testSh] Running shell script
+ ls -lrt
total 0
Workspacedir///testSh@tmp/durable-ba40512f/script.sh: line 4: ${file1.zip}: bad substitution
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
Have tried Groovy suggestions per this (multiple ways) : Fetching binary or zipped uploaded files in Jenkins - Windows cannot open the folder . The Compressed(zipped) Folder is invalid , but no luck on making this work.
ls
command. Tried looking up on server as well, but don't see it is present under ${WORKSPACE} or temp dir or any other directory.. Any pointers on locating stored/uploaded file from file-parameter Jenkins job would help – vinWin