Handle multiple search extension passed by JJB 31/15631/3
authorAnil Belur <abelur@linuxfoundation.org>
Mon, 13 May 2019 09:05:24 +0000 (19:05 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Mon, 13 May 2019 09:05:24 +0000 (19:05 +1000)
`lftools deploy archives` implementation supports '-p|--pattern'
as a multi-value option and does not support processing
multi-values as a single string.

Handle multiple search extension / patterns passed by upstream
${ARCHIVE_ARTIFACTS} param as a single string by spliting these values
before being passed to `lftools deploy archive`.

Issue: RELENG-2013
Change-Id: Id524a291a7fe03ea6f518def94b0f4ebf0974164
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml [new file with mode: 0644]
shell/logs-deploy.sh

diff --git a/releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml b/releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml
new file mode 100644 (file)
index 0000000..5fd560d
--- /dev/null
@@ -0,0 +1,42 @@
+---
+fixes:
+  - |
+    Handle multiple search extension or patterns passed by upstream JJB
+    ARCHIVE_ARTIFACTS param as a single string by spliting these values
+    before being passed to ``lftools deploy archives``.
+
+    .. code-block:: bash
+
+       ARCHIVE_ARTIFACTS="**/*.prop \
+                         **/*.log \
+                         **/target/surefire-reports/*-output.txt \
+                         **/target/failsafe-reports/failsafe-summary.xml \
+                         **/hs_err_*.log **/target/feature/feature.xml"
+
+    For example, the above env variable passed to the script and to
+    ``lftools deploy archives`` as:
+
+    .. code-block:: bash
+
+       lftools deploy archives -p **/*.prop \
+                         **/*.log \
+                         **/target/surefire-reports/*-output.txt \
+                         **/target/failsafe-reports/failsafe-summary.xml \
+                         **/hs_err_*.log **/target/feature/feature.xml \
+                         "$NEXUS_URL" \
+                         "$NEXUS_PATH" \
+                         "$WORKSPACE"
+
+    The correct way of passing this as per lftools implmentation is:
+
+    .. code-block:: bash
+
+       lftools deploy archives -p '**/*.prop' \
+                         -p '**/*.log' \
+                         -p '**/target/surefire-reports/*-output.txt' \
+                         -p '**/target/failsafe-reports/failsafe-summary.xml' \
+                         -p '**/hs_err_*.log' \
+                         -p '**/target/feature/feature.xml' \
+                         "$NEXUS_URL" \
+                         "$NEXUS_PATH" \
+                         "$WORKSPACE"
index 359642a..eae4895 100644 (file)
@@ -19,8 +19,18 @@ else
     nexus_url="${NEXUSPROXY:-$NEXUS_URL}"
     nexus_path="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
 
-    lftools deploy archives -p "${ARCHIVE_ARTIFACTS:-}" "$nexus_url" \
-            "$nexus_path" "$WORKSPACE"
+    # Handle multiple search extensions as separate values to '-p|--pattern'
+    set -f # Disable pathname expansion
+    IFS=' ' read -r -a search_exts <<< "${ARCHIVE_ARTIFACTS:-}"
+    pattern_opts=()
+    for search_ext in "${search_exts[@]}";
+    do
+        pattern_opts+=("-p" "$search_ext")
+    done
+
+    lftools deploy archives "${pattern_opts[@]}" "$nexus_url" "$nexus_path" \
+            "$WORKSPACE"
+    set +f  # Enable pathname expansion
     lftools deploy logs "$nexus_url" "$nexus_path" "${BUILD_URL:-}"
 
     echo "Build logs: <a href=\"$LOGS_SERVER/$nexus_path\">$LOGS_SERVER/$nexus_path</a>"