Merge "Improve branch cutting scripts"
[releng/builder.git] / jjb / include-raw-update-p2composite-metadata.sh
index f4223af4a137feab5b9faad7d107ff576868ee09..666729c52ccd5942604835c47f26fa69a3ead560 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+# SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2016 The Linux Foundation and others.
 #
@@ -9,15 +9,25 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
-EPOCH_DATE=`date +%s%3N`
-MVN_METADATA=`echo $P2ZIP_URL | sed 's,/*[^/]\+/*$,,' | sed 's,/*[^/]\+/*$,,'`/maven-metadata.xml
+# If we detect a snapshot build then there is no need to run this script.
+# YangIDE has indicated that the only want the latest snapshot released to
+# the snapshot directory.
+if echo "$P2ZIP_URL" | grep opendaylight.snapshot; then
+    exit 0
+fi
+if [[ "$P2ZIP_URL" == "" ]]; then
+    exit 0
+fi
+
+EPOCH_DATE=$(date +%s%3N)
+MVN_METADATA=$(echo "$P2ZIP_URL" | sed 's,/*[^/]\+/*$,,' | sed 's,/*[^/]\+/*$,,')/maven-metadata.xml
 P2_COMPOSITE_ARTIFACTS=compositeArtifacts.xml
 P2_COMPOSITE_CONTENT=compositeContent.xml
 
-wget $MVN_METADATA -O maven-metadata.xml
+wget "$MVN_METADATA" -O maven-metadata.xml
 
-VERSIONS=`xmlstarlet sel -t -m "/metadata/versioning/versions" -v "version" maven-metadata.xml`
-NUM_VERSIONS=`echo $VERSIONS | wc -w`
+VERSIONS=$(xmlstarlet sel -t -m "/metadata/versioning/versions" -v "version" maven-metadata.xml)
+NUM_VERSIONS=$(echo "$VERSIONS" | wc -w)
 
 
 ##
@@ -109,7 +119,7 @@ cat > deploy-composite-repo.xml <<EOF
               <serverId>opendaylight-p2</serverId>
               <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/p2repos/content-compressed</repositoryUrl>
               <file>composite-repo.zip</file>
-              <repositoryPath>org.opendaylight.$PROJECT</repositoryPath>
+              <repositoryPath>org.opendaylight.$PROJECT/release</repositoryPath>
             </configuration>
           </execution>
         </executions>