How to save uploaded file under original file name in Jenkins Parameterized Build \"File Parameter\"?
The "File" Parameter of the Jenkins Parameterized Build always gets the same name in your job.
We were able to sort-of-bypass this by specifying two parameters:
In our script, we took the file as we got it via the first parameter,
then renamed it as the second.
(the user had to Paste the same value to both of the fields...)
UPDATE:
As mentioned by Nux (and James Ruskin), this issue was resolved around 2011,
so you now have the ability to access the original file, in the following way:
If, for example, your File-Parameter is named File1,
then your script gets the content of that file in File1
and it can access the original file by using the local parameter ${File1}
.
I suspect it gets tricky when the script and the user are not on the same OS,
i.e.: the user writes a path in Windows and the script runs on a Unix
You can get original file name from the parameter with the same name as the parameter name (file location field).
For example if the file location is my_file
then you can rename it to original by executing:
mv my_file ${my_file}