Split multipatch into two phases, clone and build 18/71518/6
authorStephen Kitt <skitt@redhat.com>
Fri, 27 Apr 2018 15:42:49 +0000 (17:42 +0200)
committerLuis Gomez <ecelgp@gmail.com>
Tue, 29 May 2018 19:17:54 +0000 (19:17 +0000)
This loops through all the patches and sets them up before starting a
build. This ensures that we fail fast if the patch specification is
incorrect, or if a patch can’t be checked out. It also paves the way
for better organisation of the build (automatic calculation of the
order...).

To make testing easier, this also adds a shebang and makes the script
executable.

Change-Id: I062741204c66df6f3b5805b24c63059c1df4177d
Signed-off-by: Stephen Kitt <skitt@redhat.com>
jjb/integration/multipatch-distribution.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index ae9791d..6022254
@@ -1,3 +1,5 @@
+#!/bin/bash
+
 # TODO: 1) clean up inline todo's below :)
 # TODO: 2) Use just a topic branch to create a distribution.  see this email:
 #          https://lists.opendaylight.org/pipermail/discuss/2015-December/006040.html
@@ -83,6 +85,10 @@ fi
 echo "Patches to build: ${PATCHES_TO_BUILD}"
 IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}"
 
+# First phase: clone the necessary repos and set the patches up
+
+declare -a PROJECTS
+
 # For each patch:
 # * Clone the project.
 # * Optionally, checkout a specific (typically unmerged) Gerrit patch. If none,
@@ -114,6 +120,7 @@ do
         distribution_status="included"
     fi
     PROJECT_SHORTNAME="${PROJECT##*/}"  # http://stackoverflow.com/a/3162500
+    PROJECTS+=("${PROJECT_SHORTNAME}")
     echo "cloning project ${PROJECT}"
     git clone "https://git.opendaylight.org/gerrit/p/${PROJECT}"
     cd ${PROJECT_SHORTNAME} || exit 1
@@ -146,34 +153,42 @@ do
         # Here 'r' means release. Useful for testing Nitrogen Odlparent changes.
         find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//g'
     fi
-    # Build project
-    "$MVN" clean install \
-    -e ${fast_option} \
-    -Dstream=oxygen \
-    -Dgitid.skip=false \
-    -Dmaven.gitcommitid.skip=false \
-    --global-settings "$GLOBAL_SETTINGS_FILE" \
-    --settings "$SETTINGS_FILE" \
-    $MAVEN_OPTIONS
     cd "${BUILD_DIR}" || exit 1
-    # Since we've installed the artifacts, we can delete the build and save
-    # disk space
-    rm -rf "${PROJECT_SHORTNAME}"
 done
 
 if [ "${distribution_status}" == "not_included" ]; then
     echo "adding integration/distribution"
+    PROJECTS+=(distribution)
     # clone distribution and add it as a module in root pom
     git clone "https://git.opendaylight.org/gerrit/p/integration/distribution"
     cd distribution || exit 1
     git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
+    cd "${BUILD_DIR}" || exit 1
+fi
+
+# Second phase: build everything
+
+for PROJECT_SHORTNAME in "${PROJECTS[@]}"; do
+    pushd "${PROJECT_SHORTNAME}" || exit 1
     # Build project
     "$MVN" clean install \
-    -e -Pq \
+    -e ${fast_option} \
     -Dstream="$DISTROSTREAM" \
+    -Dgitid.skip=false \
+    -Dmaven.gitcommitid.skip=false \
     --global-settings "$GLOBAL_SETTINGS_FILE" \
     --settings "$SETTINGS_FILE" \
     $MAVEN_OPTIONS
-    cd "${BUILD_DIR}" || exit 1
-fi
+    # Since we've installed the artifacts, we can clean the build and save
+    # disk space
+    "$MVN" clean \
+    -e ${fast_option} \
+    -Dstream="$DISTROSTREAM" \
+    -Dgitid.skip=false \
+    -Dmaven.gitcommitid.skip=false \
+    --global-settings "$GLOBAL_SETTINGS_FILE" \
+    --settings "$SETTINGS_FILE" \
+    $MAVEN_OPTIONS
+    popd || exit 1
+done