我正在敲打这个(错误的)行为。当我在ant中执行CURL请求时,上传会生成size = 0的文件,当我在shell中执行相同的请求时,文件的大小正确。
ANT目标输出:
[echo] path.toFile=/home/marcel/gitrepos/<repo>/source/<file>.zip
[echo] path.targetFile=target/<file>.zip
[echo] ------------
[echo] curl -k -H 'X-JFrog-Art-Api: <API-KEY>
[echo] ' -T "/home/marcel/gitrepos/<repo>/delivery/<file>.zip" "https://<company>.de/artifactory/stage-dev/target/<file>.zip"
[echo] ------------
[exec] % Total % Received % Xferd Average Speed Time Time Time Current
[exec] Dload Upload Total Spent Left Speed
[exec]
[exec] {
[exec] "repo" : "stage-dev",
[exec] "path" : "/target/<file>.zip",
[exec] "created" : "2018-02-27T16:12:25.397Z",
[exec] "createdBy" : "<user>",
[exec] "downloadUri" : "https://<company>.de:443/artifactory/stage-dev/target/<file>.zip",
[exec] "mimeType" : "application/zip",
[exec] "size" : "0",
[exec] "checksums" : {
[exec] "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709",
[exec] "md5" : "d41d8cd98f00b204e9800998ecf8427e"
[exec] },
[exec] "originalChecksums" : {
[exec] },
[exec] "uri" : "https://<company>.de:443/artifactory/stage-dev/target/<file>.zip"
[exec] }
[exec] 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 5397k 0 752 0 0 2961 0 --:--:-- --:--:-- --:--:-- 2972
ANT片段:要使用ant执行CURL命令,我使用了以下代码段:
<property name="artifactory.url" value="https://<company>.de/artifactory/stage-dev/"/>
<target name="upload-latest-zip" depends="-read-api-key" description="=> upload latest zip to artifactory. requires (apikey-file).">
<property name="path.toFile" location="source/${<file>}"/>
<property name="path.targetFile" value="target/${<file>}"/>
<echo message="------------" />
<echo message="curl -k -H 'X-JFrog-Art-Api: ${apikey}' -T ${path.toFile} "${artifactory.url}/${path.targetFile}"" />
<echo message="------------" />
<exec executable="curl">
<arg line="-k"/>
<arg line="-H"/>
<arg line="'X-JFrog-Art-Api: ${apikey}'"/>
<arg line="-T"/>
<arg line="${path.toFile}"/>
<arg line=""${artifactory.url}/${path.targetFile}""/>
</exec>
</target>
SHELL输出为了自我测试CURL,我使用了来自ant输出的echoed命令。
marcel@Ubuntu:~/gitrepos/<repo>$ curl -k -H 'X-JFrog-Art-Api: <API-KEY>' -T "/home/marcel/gitrepos/<repo>/delivery/<file>.zip" "https://<company>.de/artifactory/stage-dev/target/<file>.zip"
{
"repo" : "stage-dev",
"path" : "/target/<file>.zip",
"created" : "2018-02-27T16:12:25.397Z",
"createdBy" : "<user>",
"downloadUri" : "https://<company>.de:443/artifactory/stage-dev/target/<file>.zip",
"mimeType" : "application/zip",
"size" : "5526727",
"checksums" : {
"sha1" : "732c7ee866c06d2988abde8ec22ad1f9268f89fb",
"md5" : "285c135f1551c2c07dec296c01d93160"
},
"originalChecksums" : {
},
"uri" : "https://<company>.de:443/artifactory/stage-dev/target/<file>.zip"
not shown in this question
为了验证这种行为,我还在(上传)CURL命令周围包装了一个shell脚本,并从ant调用了shell脚本,而不是直接调用CURL。但它会导致相同的行为。
目前我们只是用shell替换ant脚本。无论如何我真的想知道为什么会出现这种情况!
有人有个好主意吗? :)
附加信息:
二手软件:
变量$ {path.toFile}的价值是多少?
[echo] path.toFile=/home/marcel/gitrepos/<repo>/source/<file>.zip
[echo] ' -T "/home/marcel/gitrepos/<repo>/delivery/<file>.zip" "https://<company>.de/...
/来源或/交付?无论如何你在蚂蚁中设置两次相同变量的值吗?由于属性在ant中是不可变的,因此设置两次/更新它将不起作用。