Artifactory & Bintray API
REST API
Artifactory API
deploy artifact using REST
curl -u myUser:myP455w0rd! -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt
query artifacts by Repo and Path
curl -u user:pw -X POST -k http://mrxartifactory:8081/artifactory/api/search/aql -d "items.find({\"type\" : \"file\",\"\$and\":[{\"repo\" : {\"\$match\" : \"myRepo*\"}, \"path\" : {\"\$match\" : \"myPkg*\"} }]}).include(\"name\",\"repo\",\"path\",\"size\")"
# upload RPM to artifactory, include checksums
echo "----- get md5 checksum"
md5=$(md5sum $rpm_name | awk -F" " {'print $1'})
echo "----- get sha1 checksum"
sha1=$(sha1sum $rpm_name | awk -F" " {'print $1'})
echo "----- upload RPM to artifactory using API key"
curl -H "X-JFrog-Art-Api:${artif_key}" -H "X-Checksum-Md5:${md5}" -H "X-Checksum-Sha1:${sha1}" -X PUT "http://${artif_server}:${artif_port}/artifactory/${artif_repo_path}/${rpm_name}" -T $rpm_name
get all artifacts from a build
curl -u user:pw -X GET http://mrxteamcity:8111/httpAuth/app/rest/builds/id:51/artifacts/children -H "Content-Type: application/xml"
Bintray API
push artifact from Teamcity to Bintray
# get artifact name
product=$(ls %system.teamcity.build.checkoutDir% | grep myProduct)
# push to bintray
curl -T %system.teamcity.build.checkoutDir%/$product -u%bintray_user%:%bintray_key% https://api.bintray.com/org_name/repo_name/pkg_name/version_name/$product
# publish binaries on Bintray
curl -X POST -u%bintray_user%:%bintray_key% https://api.bintray.com/content/org_name/repo_name/pkg_name/version_name/publish
get all packages in a repo
curl -u<USERNAME>:<API_KEY> -X GET https://api.bintray.com/repos/<ORG NAME>/<REPO NAME>/packages | jq .
get all files under a specific pkg
curl -u<USERNAME>:<API-KEY> -X GET https://api.bintray.com/packages/<ORG NAME>/<REPO NAME>/<PKG NAME>/versions/<VERSION NUMBER>/files | jq .
delete a file in a package
curl -u <USER>:<API-KEY> -X DELETE https://api.bintray.com/content/<ORG NAME>/<REPO_NAME>/<name of file>
curl -u admin:2fc03434xxxx -X DELETE https://api.bintray.com/content/jfrog/test_rpms/myapp-0.1-x64.rpm