X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fcreate-netrc.sh;h=a123be8d90d8b4d3c2507b3101e88457438cb0af;hb=6eefde1f463638b5021c2ec96eb67a017d379f1f;hp=35bc0c3be8493999cf282efed1e900fc6b403d5d;hpb=2069fa3b9c656c59fc93c77bf0ba80a18c0ddc00;p=releng%2Fglobal-jjb.git diff --git a/shell/create-netrc.sh b/shell/create-netrc.sh index 35bc0c3b..a123be8d 100644 --- a/shell/create-netrc.sh +++ b/shell/create-netrc.sh @@ -10,17 +10,32 @@ ############################################################################## echo "---> create-netrc.sh" -# Ensure we fail the job if any steps fail. -set -eu -o pipefail - -NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}" +if [ -z "$ALT_NEXUS_URL" ]; then + NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}" +else + NEXUS_URL="${ALT_NEXUS_URL}" +fi CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \ -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \ -v x:username -o ":" -v x:password \ "$SETTINGS_FILE") +# Ensure we fail the job if any steps fail. +set -eu -o pipefail + +# Handle when a project chooses to not archive logs to a log server +# in other cases if CREDENTIAL is not found then fail the build. +if [ -z "$CREDENTIAL" ] && [ "$SERVER_ID" == "logs" ]; then + echo "WARN: Log server credential not found." + exit 0 +elif [ -z "$CREDENTIAL" ]; then + echo "ERROR: Credential not found." + exit 1 +fi + machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}') user=$(echo "$CREDENTIAL" | cut -f1 -d:) pass=$(echo "$CREDENTIAL" | cut -f2 -d:) -echo "machine $machine login $user password $pass" > ~/.netrc +set +x # Disable `set -x` to prevent printing passwords +echo "machine ${machine%:*} login $user password $pass" > ~/.netrc