Skip to content

Instantly share code, notes, and snippets.

@qrkourier
Last active May 22, 2024 15:49
Show Gist options
  • Save qrkourier/5abb129ea22bdf981b11551c6d37789b to your computer and use it in GitHub Desktop.
Save qrkourier/5abb129ea22bdf981b11551c6d37789b to your computer and use it in GitHub Desktop.
Delete a bad version from DEB/RPM Artifactory repos
(
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