Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Parameterized Build upload file and save original file name

How to save uploaded file under original file name in Jenkins Parameterized Build "File Parameter"?

like image 280
pavel.mileshchenko Avatar asked Dec 19 '12 11:12

pavel.mileshchenko


2 Answers

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}
like image 75
Nux Avatar answered Oct 06 '22 09:10

Nux


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:

  • One parameter is of type File - this gets the content to the file.
  • Other parameter is of type String - this gets the original name of the file.

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

like image 45
Gonen Avatar answered Oct 06 '22 10:10

Gonen