Created
February 26, 2021 08:17
-
-
Save romainbsl/c60987c4852f9e56e3b0ebc51ee2b7c9 to your computer and use it in GitHub Desktop.
Sonatype: drop a staging repository
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
#!/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