Merge "Change array in loop bashism to satisfy shellcheck"
[releng/builder.git] / jjb / include-raw-generate-p2pom.sh
index 5e5ffde6f8c160d925dde4a958b695a5a2d9c8a7..85ae3a66025fcd2c459156e9427fb31b1a4c40f4 100644 (file)
@@ -9,12 +9,25 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
-FILE_NAME=`echo $P2ZIP_URL | awk -F'/' '{ print $NF }'`
-VERSION=`echo $P2ZIP_URL | awk -F'/' '{ print $(NF-1) }'`
+if [[ "$P2ZIP_URL" == "" ]]; then
+    P2ZIP_URL=opendaylight.snapshot/$(find . -name "*.zip" -type f -exec ls "{}" + | head -1)
+    FILE_NAME=$(echo "$P2ZIP_URL" | awk -F'/' '{ print $NF }')
+    RELEASE_PATH="snapshot"
+else
+    FILE_NAME=$(echo "$P2ZIP_URL" | awk -F'/' '{ print $NF }')
+    VERSION=$(echo "$P2ZIP_URL" | awk -F'/' '{ print $(NF-1) }')
+    RELEASE_PATH="release/$VERSION"
+    wget --quiet "$P2ZIP_URL" -O "$FILE_NAME"
+fi
 
-wget $P2ZIP_URL -O $FILE_NAME
+# If we detect a snapshot build then release to a snapshot repo
+# YangIDE has indicated that the only want the latest snapshot released to
+# the snapshot directory.
+if echo "$P2ZIP_URL" | grep opendaylight.snapshot; then
+    RELEASE_PATH="snapshot"
+fi
 
-cat > ${WORKSPACE}/pom.xml <<EOF
+cat > "${WORKSPACE}/pom.xml" <<EOF
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.$PROJECT</groupId>
@@ -47,7 +60,7 @@ cat > ${WORKSPACE}/pom.xml <<EOF
               <serverId>opendaylight-p2</serverId>
               <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/p2repos/content-compressed</repositoryUrl>
               <file>$FILE_NAME</file>
-              <repositoryPath>org.opendaylight.$PROJECT/$VERSION</repositoryPath>
+              <repositoryPath>org.opendaylight.$PROJECT/$RELEASE_PATH</repositoryPath>
             </configuration>
           </execution>
         </executions>