url="http://$abc/$def/$qwe/file.a?properties"
curl -u "$user":AP"$pass" "$url"
行不起作用。 我发现没有属性的错误。 该文件存在,具有校验和路径是正确的。
将MD5校验和纳入VAR并检查命令是否成功。
一个选项是使用:
https://www.jfrog.com/confluence/display/rtf/artifactory+Rest+papi+papi #artifactoryrestapyrestapi-itemproperties
curl http://artifactory.host/api/storage/libs-release-local/org/acme
curl http://artifactory.host/api/storage/libs-release-local/org/acme | | jq .checksums.sha1
执行头部请求。
curl -I http://$abc/$def/$qwe/file.a
然后Grep进行您想要的校验和
您可以使用此
RestAPI获取文件信息,然后JQ
过滤MD5。
例如:url="http://localhost:8081/artifactory"
pathToFile="path/to/file"
curl -u "$user":"$pass" "$url/api/storage/$pathToFile" | jq '.checksums.md5'
我更喜欢使用原始下载URL的方法,因此我的脚本可以使用相同的URL进行下载和获取校验和获取:
echo "The MD5 is: $(curl -I --silent http://$abc/$def/$qwe/file.a | grep X-Checksum-Md5 | awk 'BEGIN{RS="\r\n"}{print $2}')"
echo "The SHA256 is: $(curl -I --silent http://$abc/$def/$qwe/file.a | grep X-Checksum-Sha256 | awk 'BEGIN{RS="\r\n"}{print $2}')"
尴尬的一部分是消除不良的 我的文物正在返回的马车返回,否则它会弄乱您想在同一Echo中打印的任何东西(因此在所有情况下可能不需要,但在此包含在这里以进行完整)。