Last active
May 22, 2024 15:49
-
-
Save qrkourier/5abb129ea22bdf981b11551c6d37789b to your computer and use it in GitHub Desktop.
Delete a bad version from DEB/RPM Artifactory repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
set -euxopipefail | |
ARTIFACTORY_REPO='zitipax-openziti-(rpm|deb)-stable' | |
DELETE="--dry-run" | |
: DELETE="--quiet" | |
BAD_VERSION=1.1.8 | |
declare -a ARTIFACTS=(openziti{,-controller,-router}) | |
if [[ $DELETE =~ quiet ]] && { | |
echo "WARNING: permanently deleting" >&2; | |
sleep 9; | |
} | |
for META in rpm.metadata deb; | |
do | |
for ARTIFACT in ${ARTIFACTS[@]}; | |
do | |
while read; | |
do | |
jf rt search --props "${META}.name=${ARTIFACT};${META}.version=${BAD_VERSION}" "${REPLY}/*" \ | |
| jq '.[].path' \ | |
| xargs -rl jf rt del $DELETE; | |
done< <( | |
jf rt cl -sS /api/repositories \ | |
| jq --raw-output --arg artifactory "${ARTIFACTORY_REPO}" '.[]|select(.key|match($artifactory))|.key' | |
) | |
done | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment