【发布时间】:2018-02-28 07:04:30
【问题描述】:
我目前正在反对这种(错误的)行为。 当我在 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 sn-p: 为了用 ant 执行 CURL 命令,我使用了这个 sn-p:
<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 脚本。无论如何,我真的很想知道为什么会发生这种行为!
有人是个好主意吗? :)
其他信息:
使用过的软件:
- Ubuntu 16.04.3 LTS
- GNU bash,版本 4.3.48(1)-release (x86_64-pc-linux-gnu)
- Apache Ant(TM) 版本 1.10.1 编译于 2017 年 2 月 2 日
- curl 7.47.0 (x86_64-pc-linux-gnu)
- java-8-openjdk-amd64
- Artifactory Enterprise 5.3.0
【问题讨论】:
标签: bash curl ant artifactory put