Jenkins Parameterized Build upload file and save original file name

后端 未结 2 1725
遇见更好的自我
遇见更好的自我 2021-01-04 07:03

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

相关标签:
2条回答
  • 2021-01-04 07:23

    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

    0 讨论(0)
  • 2021-01-04 07:24

    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}
    
    0 讨论(0)
提交回复
热议问题