bash Jenkins上传带有文件参数的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46232238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins upload file with File Parameter
提问by corny
I want to upload files with Jenkins using File Parameter, from my loacal PC, from anywhere except the project workspace and send it vi FTP(with put). The following problem appears:when the file uploaded is anywhere on my PC except the project workspace ,the name is changed in "file location"(which in my case is "file" see the screenshot), from File Parameter. How to obtain the browse path in this scenario in order to have the correct path to file name (/browse/path/to/the/file/$file) respective the original name. If there is another method,plugin in Jenkins to upload any file from PC please let me know. Thank you! The bash code is:
我想使用文件参数与 Jenkins 一起上传文件,从我的本地 PC,从项目工作区以外的任何地方,并通过 FTP(使用 put)发送它。出现以下问题:当上传的文件位于我 PC 上除项目工作区之外的任何位置时,名称在“文件位置”(在我的情况下为“文件”,请参见屏幕截图)中更改,来自文件参数。在这种情况下如何获取浏览路径,以便获得正确的文件名路径 (/browse/path/to/the/file/$file) 和原始名称。如果有另一种方法,在 Jenkins 中插入插件从 PC 上传任何文件,请告诉我。谢谢!bash 代码是:
#!C:\cygwin64\bin\bash.exe
export PATH=$PATH:/usr/bin
for (( c=0; c<$NumberOFjobs; c++)) ;do
USER=usser
PASS=pass
ftp -inv $IP <<EOF
user $USER $PASS
cd /D:/builds2
put $file
bye
EOF
ls -l
done
exit 0
FileParameterscreenIf I use:"put file" works "correctly" except the original file name is changed. If I use:"put $file" which give the original file name, the "File not found" error occurred.
FileParameterscreen如果我使用:“放置文件”工作“正确”,但原始文件名已更改。如果我使用:“put $file”给出原始文件名,则会发生“找不到文件”错误。
回答by corny
The answer to my problem is:
我的问题的答案是:
mv file ${file}.
I found it here: Jenkins Parameterized Build upload file and save original file name
我在这里找到它: Jenkins Parameterized Build upload file and save original file name