Skip to content

Instantly share code, notes, and snippets.

@sstone
Forked from romainbsl/drop-repository.sh
Created March 9, 2021 09:27
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 sstone/6ce5db078c9d3a37140bbfa29be1ae91 to your computer and use it in GitHub Desktop.
Save sstone/6ce5db078c9d3a37140bbfa29be1ae91 to your computer and use it in GitHub Desktop.
Sonatype: drop a staging repository
#!/usr/bin/env bash
username=
password=
stagedRepositoryId=
while [ "$1" != "" ]; do
case $1 in
-u | --username)
shift
username="$1"
;;
-p | --password)
shift
password="$1"
;;
-id | --stagedRepositoryId)
shift
stagedRepositoryId="$1"
;;
*)
echo "Unknown command $1"
exit 1
;;
esac
shift
done
if test -z "$username" || test -z "$password" || test -z "$stagedRepositoryId"
then
echo "Missing parameter(s) for sonatype 'username' | 'password' | 'stagedRepositoryId'."
exit 1
fi
response=$(curl -s --request POST -u "$username:$password" \
--url https://oss.sonatype.org/service/local/staging/bulk/drop \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{ "data" : {"stagedRepositoryIds":["'"$stagedRepositoryId"'"], "description":"Drop '"$stagedRepositoryId"'." } }')
if [ ! -z "$response" ]; then
echo "Error while dropping repository $stagedRepositoryId : $response."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment