Skip to content

Instantly share code, notes, and snippets.

@vlfig
Last active December 22, 2015 20:19
Show Gist options
  • Save vlfig/6526078 to your computer and use it in GitHub Desktop.
Save vlfig/6526078 to your computer and use it in GitHub Desktop.
Nexus SHA1 lookup script
#!/bin/bash
NEXUS_BASE_URL='https://repository.apache.org/'
NRA_SEG='service/local/data_index?sha1='
echo "Using $NEXUS_BASE_URL$NRA_SEG<SHA1 checksum>"
echo
lookup()
{
chksum=`shasum $1`
url=$NEXUS_BASE_URL$NRA_SEG"${chksum:0:40}"
result=`curl -s ${url}`
count=`echo ${result} | sed 's|^.*<totalCount>\(.*\)</totalCount>.*$|\1|'`
if [ $count -gt 0 ];then
gav=`echo ${result} | sed 's|^.*<groupId>\(.*\)</groupId.*artifactId>\(.*\)</artifactId.*version>\(.*\)</version>.*$|\1:\2:\3|'`
echo "$1 -> ($gav)"
else
echo "$1 -> ()"
fi
}
for target in "$@"
do
lookup $target
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment