Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Last active February 17, 2025 13:54
Show Gist options
  • Save jdmichaud/2c710d006d8545de9d6b204cfa4a1bc4 to your computer and use it in GitHub Desktop.
Save jdmichaud/2c710d006d8545de9d6b204cfa4a1bc4 to your computer and use it in GitHub Desktop.
artifactory
ARTIFACTORY_DOMAIN=$(grep '^registry=' ~/.npmrc | awk -F'=' '{print $2}' | awk -F/ '{print $3}')
ARTIFACTORY_TOKEN=$(grep '^//${ARTIFACTORY_DOMAIN}' ~/.npmrc | \
awk -F':' '{ print $2 }' | \
awk -F'_auth=' '{ print $2 }' | \
tr -d '"\r' | \
base64 -d | \
awk -F':' '{ print $2 }')
curl -H "Authorization: Bearer ${ARTIFACTORY_TOKEN}" \
"https://${ARTIFACTORY_DOMAIN}/artifactory/api/storage/${PATH_TO_RESOURCE}?list&deep=1&listFolders=1&mdTimestamps=1" \
| jq '.files |= sort_by(.lastModified)' \
| jq '.files[-1].uri' \
| tr -d '"\r'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment