artifactory api 在shell中的调用

1. 获取files list

  curl -u ${JFROG_USER}:${JFROG_PWD} -X POST ${ARTIFACTORY_URL}/api/search/aql -H 'Content-Type: text/plain' -d \
    "items.find({ \
        \"type\" : \"file\", \
        \"repo\" : {\"\$eq\" : \"${atf_repo}\"}, \
        \"path\":{\"\$match\":\"${atf_path}*\"} \
        }).include(\"name\",\"repo\",\"path\",\"actual_md5\",\"type\")" | tee "${tmp_file}"

2.获取多少天创建的files list

  curl -u ${JFROG_USER}:${JFROG_PWD} -X POST ${ARTIFACTORY_URL}/api/search/aql -H 'Content-Type: text/plain' -d \
    "items.find({ \
        \"type\" : \"file\", \
        \"repo\" : {\"\$eq\" : \"${repo}\"}, \
        \"\$or\": [\
          {\
            \"\$and\": [\
              {\
                \"created\": { \"\$before\":\"${retention_days}d\" }\
              }\
            ]\
          }\
        ]\
        }).include(\"name\",\"repo\",\"path\",\"actual_md5\",\"type\")" \
    | jq '.results' \
    | jq '.[] |  "\(.repo)/\(.path)/\(.name)"' \
    | sed 's/"//g' \
    | sed "s#^#${ARTIFACTORY_URL}/#g"

3. 下载文件

curl -u ${JFROG_USER}:${JFROG_PWD} -O ${ARTIFACTORY_URL}/temp/1.txt

4.上传文件

curl -X PUT -u ${JFROG_USER}:${JFROG_PWD} -T 1.txt "${ARTIFACTORY_URL}/temp/1.txt"
# deploy files with property
curl -X PUT -u ${JFROG_USER}:${JFROG_PWD} -T 1.sh "${ARTIFACTORY_URL}/temp/1.sh;retention.days=20;build_os=ubuntu-18.04;"

5. copy 文件

curl -X POST -u ${JFROG_USER}:${JFROG_PWD} ${ARTIFACTORY_URL}/api/copy/temp/1.txt?to=temp/2.txt

6. 删除文件

curl -X DELETE -u ${JFROG_USER}:${JFROG_PWD} ${ARTIFACTORY_URL}/temp/1.txt

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值