Skip to content

Commit

Permalink
Create nexus.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
DeekshithSN authored Feb 14, 2022
1 parent 25f3cef commit 876d1e6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions shell_scripts/nexus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/sh


help(){
echo "the way you exected script is wrong "
echo "the script options are count, hosted and proxy"
echo "example to run this script sh nexus-report.sh count"
exit 137
}

if [ "$1" = "count" ]
then
curl -s -X 'GET' 'http://nexus-ip:8081/service/rest/v1/repositories' -H 'accept: application/json' | jq .[].name | wc -l
elif [ "$1" = "hosted" ]
then
echo "Repo Name"
curl -s -X 'GET' 'http://nexus-ip:8081/service/rest/v1/repositories' -H 'accept: application/json' | jq ' .[] | select ( .type == "hosted" ) | .name ' | sed 's/"//g'
elif [ "$1" = "proxy" ]
then
echo "Repo Name, Remote URL"
curl -s -X 'GET' 'http://nexus-ip:8081/service/rest/v1/repositories' -H 'accept: application/json' | jq ' .[] | select ( .type == "proxy" ) | .name + "," + .attributes.proxy.remoteUrl ' | sed 's/"//g'
elif [[ "$1" = "admin" && "$2" = "mrc" ]]
then
echo "please enter maven repo name"
read repo
sed -i "s/REPONAME/$repo/g" maven.json
curl -s -H "Content-Type: application/json" -u admin:admin -d @maven.json 'http://nexus-ip:8081/service/rest/v1/repositories/maven/hosted'
if [ $? -eq 0 ]
then
echo "the repo creation succesful "
else
echo "repo creation failed"
fi
sed -i "s/$repo/REPONAME/g" maven.json
else
help
fi

0 comments on commit 876d1e6

Please sign in to comment.