我正在尝试将文件从本地目录上传到远程目录。我编写了一个 Groovy 库来执行此操作。
def file = "$WORKPLACE/**/*-${BUILD_NUMBER}-*/file.txt"
pulic uploadArtifct (String user, String password, String file, String
location) {
def cred = "${user}:${password}"
def cmd = ["curl", "-v", "-u", cred, "-F", "files=@${file}", ${location}]
try {
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println sout
} catch (Exception e) {
throw new RuntimeExceptipon("Cannot execute curl, exception: [${e.getClass().getName()} - '${e.getMessage()}']")
}
}
但是,上述操作失败并出现错误:
java.lang.RuntimeException: Cannot execute curl, exception: [java.lang.RuntimeException - 'Error running ; stdout='', stderr='warning:setting file
Warning: /app/jenkins/workspace/Job/**/*-10-*/file.txt
Warning: failed!
如何确保文件设置正确?还有就是-F
方法正确吗?
那个错误信息
Cannot execute curl, exception: [java.lang.RuntimeException - 'Error running ; stdout='', stderr='warning:setting file
Warning: /app/jenkins/workspace/Job/**/*-10-*/file.txt
Warning: failed!
被看到在另一个背景 https://stackoverflow.com/q/51307393/6309
该路径需要一个“at”(@
.jtl 文件路径之前的 ) 符号
-F "jtl_file=@/path/to/file"
在您的情况下,双引号可能会丢失。
"\"files=@${file}\""
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)