fix uploading of plugin/type files 09/20409/2
authorTony Hansen <tony@att.com>
Tue, 24 Oct 2017 17:43:05 +0000 (17:43 +0000)
committerTony Hansen <tony@att.com>
Tue, 24 Oct 2017 19:10:37 +0000 (19:10 +0000)
fixed the MVN_SERVER_ID variable used to extract values from the settings.xml
file to be MVN_RAWREPO_SERVERID with a backup value of ecomp-raw.

upload to both NEXUS/GROUPID/types/foo/foo.h AND NEXUS/GROUPID/{snapshots,releases}/types/foo/foo.h

Change-Id: I33545b919679b13c02aaf28d8b3ef42195c606bb
Signed-off-by: Tony Hansen <tony@att.com>
Issue-ID: CCSDK-128
Signed-off-by: Tony Hansen <tony@att.com>
mvn-phase-script.sh

index 38aa669..b23eb86 100755 (executable)
@@ -42,6 +42,27 @@ echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY"
 # mvn phase in life cycle
 MVN_PHASE="$2"
 
+function setnetrc {
+  # Turn off -x so won't leak the credentials
+  set +x
+  serverid=${MVN_RAWREPO_SERVERID:-ecomp-raw}
+  hostport=$(echo $1 | cut -f3 -d /)
+  host=$(echo $hostport | cut -f1 -d:)
+  settings=${SETTINGS_FILE:-$HOME/.m2/settings.xml}
+  echo machine $host login $(xpath -q -e "//servers/server[id='$serverid']/username/text()" $settings) password $(xpath -q -e "//servers/server[id='$serverid']/password/text()" $settings) >$HOME/.netrc
+  chmod 600 $HOME/.netrc
+  set -x
+}
+
+function putraw {
+  case "$MVN_PROJECT_VERSION" in 
+    *SNAPSHOT ) export subdir=snapshots ;;
+    * ) export subdir=releases ;;
+  esac 
+  curl -X PUT -H "Content-Type: $3" --netrc --upload-file $1 --url $REPO/$2
+  curl -X PUT -H "Content-Type: $3" --netrc --upload-file $1 --url $REPO/$subdir/$2
+}
+
 case $MVN_PHASE in
 clean)
   echo "==> clean phase script"
@@ -93,19 +114,6 @@ deploy)
   echo "==> deploy phase script"
   # Just upload files to Nexus
   set -e -x
-  function setnetrc {
-    # Turn off -x so won't leak the credentials
-    set +x
-    hostport=$(echo $1 | cut -f3 -d /)
-    host=$(echo $hostport | cut -f1 -d:)
-    settings=${SETTINGS_FILE:-$HOME/.m2/settings.xml}
-    echo machine $host login $(xpath -q -e "//servers/server[id='$MVN_SERVER_ID']/username/text()" $settings) password $(xpath -q -e "//servers/server[id='$MVN_SERVER_ID']/password/text()" $settings) >$HOME/.netrc
-    chmod 600 $HOME/.netrc
-    set -x
-  }
-  function putraw {
-    curl -X PUT -H "Content-Type: $3" --netrc --upload-file $1 --url $REPO/$2
-  }
   setnetrc $REPO
   PLUGIN_FILE=$(echo $PLUGIN_NAME-*.wgn)
   putraw $PLUGIN_FILE plugins/$PLUGIN_FILE application/gzip