From cfe54b794b3814f288009b796e82668ba8846ca1 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Mon, 13 May 2019 19:05:24 +1000 Subject: [PATCH] Handle multiple search extension passed by JJB `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 --- ...e-multi-search-extensions-47a88a33ae39456f.yaml | 42 ++++++++++++++++++++++ shell/logs-deploy.sh | 14 ++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml diff --git a/releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml b/releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml new file mode 100644 index 00000000..5fd560de --- /dev/null +++ b/releasenotes/notes/handle-multi-search-extensions-47a88a33ae39456f.yaml @@ -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" diff --git a/shell/logs-deploy.sh b/shell/logs-deploy.sh index 359642ad..eae48951 100644 --- a/shell/logs-deploy.sh +++ b/shell/logs-deploy.sh @@ -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: $LOGS_SERVER/$nexus_path" -- 2.16.6