Skip to content

Commit

Permalink
Script reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlissett committed Feb 15, 2022
1 parent 392cc83 commit b0e8dd1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/resources/bin/crawl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function getArtifactUrl {
PACKAGING=jar
CLASSIFIER=

set -o pipefail

while getopts "s:g:a:v:r:c:e:" OPTION
do
case ${OPTION} in
Expand Down Expand Up @@ -71,13 +73,13 @@ function getArtifactUrl {
if [[ ${VERSION} == "LATEST" || ${VERSION} == *SNAPSHOT* ]] ; then

if [[ "${VERSION}" == "LATEST" ]] ; then
VERSION=$(xmllint --xpath "//metadata/versioning/versions/version[last()]/text()" <(curl -Ss "${SONAR_REDIRECT_URL}/maven-metadata.xml"))
VERSION=$(xmllint --xpath "//metadata/versioning/versions/version[last()]/text()" <(curl -Ss --fail "${SONAR_REDIRECT_URL}/maven-metadata.xml"))
fi

if [[ "${VERSION}" == *SNAPSHOT* ]] ; then
META_PATH=${SONAR_REDIRECT_URL}/${VERSION}/maven-metadata.xml
TIMESTAMP=`curl -Ss "${META_PATH}" | xmllint --xpath "string(//timestamp)" -`
BUILD_NUMBER=`curl -Ss "${META_PATH}" | xmllint --xpath "string(//buildNumber)" -`
TIMESTAMP=`curl -Ss --fail "${META_PATH}" | xmllint --xpath "string(//timestamp)" -`
BUILD_NUMBER=`curl -Ss --fail "${META_PATH}" | xmllint --xpath "string(//buildNumber)" -`

FILENAME=${ARTIFACT_ID}-${VERSION%-SNAPSHOT}-${TIMESTAMP}-${BUILD_NUMBER}${CLASSIFIER}.${PACKAGING}
else
Expand All @@ -87,7 +89,7 @@ function getArtifactUrl {
else

if [[ ${VERSION} == "RELEASE" ]] ; then
VERSION=$(xmllint --xpath "string(//release)" <(curl -Ss "${SONAR_REDIRECT_URL}/maven-metadata.xml"))
VERSION=$(xmllint --xpath "string(//release)" <(curl -Ss --fail "${SONAR_REDIRECT_URL}/maven-metadata.xml"))
fi

FILENAME=${ARTIFACT_ID}-${VERSION}${CLASSIFIER}.${PACKAGING}
Expand Down

0 comments on commit b0e8dd1

Please sign in to comment.