我目前正在对此(错误(行为敲打我的头。当我在ANT中执行卷曲请求时,上传会导致 size = 0 的文件,并且当我在Shell中执行相同的请求时,文件具有正确的size 。/p>
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执行卷曲命令,我使用了此片段:
<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输出为了测试卷曲的自我,我使用了蚂蚁输出中的回声命令。
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
要验证此行为,我还将shell脚本包裹在(上传(卷曲命令周围,并从ant调用shell脚本,而不是直接调用卷曲。但这会导致相同的行为。
目前,我们只用外壳代替蚂蚁脚本。无论如何,我真的想知道为什么会发生这种行为!
有人一个好主意?:(
其他信息:
使用的软件:
- 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
- 文物企业5.3.0
变量$ {path.tofile}?
的值是多少[echo] path.toFile=/home/marcel/gitrepos/<repo>/source/<file>.zip
[echo] ' -T "/home/marcel/gitrepos/<repo>/delivery/<file>.zip" "https://<company>.de/...
/source还是/送货?无论如何,您是否在ANT中将同一变量的值设置两次?由于属性在ANT中是不可变的,因此将其设置两次/更新它将无法正常工作。
有点晚了,但是在我的情况下,API-KEY最终有一个断路。使用&lt; stripline breaks/&gt; sitlline breaks。
<target name="upload">
<loadfile property="apikey" srcFile="${user.home}/.artifactory-secrets">
<filterchain>
<striplinebreaks/>
<replaceregex pattern=".*:(.*)" replace="1"/>
</filterchain>
</loadfile>
<echo message="${basedir}" />
<exec executable="curl" dir="${basedir}">
<arg value="-svL" />
<arg line="-H 'X-JFrog-Art-Api:${apikey}'" />
<arg value="-H" />
<arg value="content-type:application/octet-stream" />
<arg value="-T" />
<arg file="${basedir}/${dist}/myfile-${appversion}.jar" />
<arg value="https://artifactory.appdomain.cloud/artifactory/generic-local/" />
</exec>
</target>