Add lf ci-management jjb jobs
[releng/global-jjb.git] / shell / create-netrc.sh
diff --git a/shell/create-netrc.sh b/shell/create-netrc.sh
new file mode 100644 (file)
index 0000000..4a15e3b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/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
+##############################################################################
+
+NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
+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")
+
+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