Improve p2deploy scripts to support snapshot deploy 32/39132/3
authorThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 19 May 2016 23:05:36 +0000 (19:05 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 6 Jun 2016 15:09:21 +0000 (15:09 +0000)
- Will deploy a release if an opendaylight.snapshot URL is not found
- Will deploy latest SNAPSHOT build if P2ZIP_URL is blank
- Will deploy snapshot build if P2ZIP_URL contains opendaylight.snapshot

TODO:
- Currently hardcoded version to 1.1.1-SNAPSHOT it would be better if we
  can detect the latest x.y.z-SNAPSHOT automatically

Bug: 5869
Change-Id: I1fe343e0664ae8badc1f1f2bce88f66dea759c19
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/include-raw-generate-p2pom.sh
jjb/include-raw-update-p2composite-metadata.sh
jjb/releng-macros.yaml
jjb/releng-templates.yaml

index 5e5ffde6f8c160d925dde4a958b695a5a2d9c8a7..8a9731703dab10264537d6e0fe213ed85568d045 100644 (file)
@@ -9,10 +9,23 @@
 # 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
 <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">
@@ -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>
index f4223af4a137feab5b9faad7d107ff576868ee09..353689b8602093e386469ea1bae3b11e3a6611cc 100644 (file)
@@ -9,6 +9,16 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
+# 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
@@ -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>
index 8c8ad088467c5593c206c062ab722352fe1aa0b2..5234161e242f8904cc37fa112f0bfa37ea309d77 100644 (file)
         - file-id: '{settings-file}'
           variable: 'SETTINGS_FILE'
 
+- builder:
+    name: releng-fetch-p2zip-if-necessary
+    builders:
+    - shell: |
+        # Cleanup any existing zips and metadata before we download the new update site
+        rm -f *.zip *.xml
+    - conditional-step:
+        condition-kind: strings-match
+        condition-string1: '$P2ZIP_URL'
+        condition-string2: ''
+        condition-basedir: workspace
+        steps:
+            # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
+            - maven-target:
+                maven-version: '{maven-version}'
+                goals: 'org.apache.maven.plugins:maven-dependency-plugin:get org.apache.maven.plugins:maven-dependency-plugin:copy -V -B -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip -DoutputDirectory=$WORKSPACE'
+                settings: '{settings}'
+                global-settings: '{global-settings}'
+
 - builder:
     name: releng-generate-p2pom
     builders:
     name: releng-update-p2composite-metadata
     builders:
     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
-    - maven-target:
-        maven-version: '{maven-version}'
-        pom: 'deploy-composite-repo.xml'
-        goals: 'clean deploy -V -Dmaven.repo.local=/tmp/r'
-        settings: '{settings}'
-        global-settings: '{global-settings}'
+    - conditional-step:
+        condition-kind: file-exists
+        condition-filename: deploy-composite-repo.xml
+        condition-basedir: workspace
+        steps:
+            - maven-target:
+                maven-version: '{maven-version}'
+                pom: 'deploy-composite-repo.xml'
+                goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
+                settings: '{settings}'
+                global-settings: '{global-settings}'
 
 - builder:
     name: releng-stage-release
index 3b6dd91265e289a3ae1a2e6b2589abbdae569daf..c39080eca03880b80cf34e89f865d54204345a06 100644 (file)
     prebuilders:
         - wipe-org-opendaylight-repo
         - jacoco-nojava-workaround
+        - releng-fetch-p2zip-if-necessary:
+            maven-version: '{mvn33}'
+            settings: '{project-settings}'
+            global-settings: '{odl-global-settings}'
         - releng-generate-p2pom
 
     maven:
         maven-name: '{mvn33}'
         root-pom: 'pom.xml'
-        goals: 'clean deploy -V -Dmaven.repo.local=/tmp/r'
+        goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
         settings: '{project-settings}'
         global-settings: '{odl-global-settings}'
         post-step-run-condition: UNSTABLE