summaryrefslogtreecommitdiffstats
path: root/shell/helm/oom-create-netrc.sh
diff options
context:
space:
mode:
authorBengt Thuree <bthuree@linuxfoundation.org>2022-12-07 09:35:13 +0000
committerGerrit Code Review <gerrit@onap.org>2022-12-07 09:35:13 +0000
commit3f87f3f858b826def65c32bc64a84d2362232d60 (patch)
tree8d6016cdb96de6a9747e2e8aab18e407f1736222 /shell/helm/oom-create-netrc.sh
parentfa5cd0607c3859e16ea977467e560f9d9e505895 (diff)
parent0d19d3bfb1d47d3dcd5fe5a6db3a8445c5a1007c (diff)
Merge "[HELM] Clean up and fix oom helm jobs"
Diffstat (limited to 'shell/helm/oom-create-netrc.sh')
-rw-r--r--shell/helm/oom-create-netrc.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/shell/helm/oom-create-netrc.sh b/shell/helm/oom-create-netrc.sh
new file mode 100644
index 000000000..1b273b1cc
--- /dev/null
+++ b/shell/helm/oom-create-netrc.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+echo "---> oom-create-netrc.sh"
+
+if [ -z "$ALT_DOCKER_URL" ]; then
+ DOCKER_URL="${DOCKER_REGISTRY:-$DOCKER_URL}"
+else
+ DOCKER_URL="${ALT_DOCKER_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" ] && [ "$SERVER_ID" == "ossrh" ]; then
+ echo "WARN: OSSRH credentials not found."
+ echo " This is needed for staging to Maven Central."
+ exit 0
+elif [ -z "$CREDENTIAL" ]; then
+ echo "ERROR: Credential not found."
+ exit 1
+fi
+
+if [ "$SERVER_ID" == "ossrh" ]; then
+ machine="oss.sonatype.org"
+else
+ machine=$(echo "$DOCKER_URL")
+fi
+
+user=$(echo "$CREDENTIAL" | cut -f1 -d:)
+pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
+
+set +x # Disable `set -x` to prevent printing passwords
+echo "machine ${machine%:*} login $user password $pass" >> ~/.netrc