Skip to content

Instantly share code, notes, and snippets.

@perfecto25
Last active October 19, 2017 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfecto25/5a207d173835d5a08c971fb1058138b3 to your computer and use it in GitHub Desktop.
Save perfecto25/5a207d173835d5a08c971fb1058138b3 to your computer and use it in GitHub Desktop.
upload pkg to artifactory
#!/bin/bash
# sample upload script to upload Postgres RPM package to Artifactory
# usage: ./upload2artifactory.sh /tmp/some-rpm-name.rpm
if [ $# -le 0 ]; then echo "missing RPM name as parameter"; exit 1; fi
rpm_location=$1
rpm_name=$(echo $rpm_location | awk '{match($1, "[^/]*$", a)}END{print a[0]}')
artif_pkg_path="/stable-rpms/p/postgres/${rpm_name}"
artif_key="Artif API KEY here"
artif_url="http://artifactory.local:8081/artifactory/${artif_pkg_path}"
echo "----- get md5 checksum"
md5=$(md5sum $rpm_location | awk -F" " {'print $1'})
echo "----- get sha1 checksum"
sha1=$(sha1sum $rpm_location | awk -F" " {'print $1'})
# upload to Artif
curl -H "X-JFrog-Art-Api:${artif_key}" -H "X-Checksum-Md5:${md5}" -H "X-Checksum-Sha1:${sha1}" -X PUT "${artif_url}" -T $rpm_location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment