From: Anil Belur Date: Mon, 13 May 2019 09:05:24 +0000 (+1000) Subject: Handle multiple search extension passed by JJB X-Git-Tag: v0.37.4^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=b20fe1623e4297dcdbc8fdd7c690c4e1cee6a005;p=releng%2Fglobal-jjb.git 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: I68130666555ed6bcc25c3173997cd46412766787 Signed-off-by: Anil Belur --- 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 aee1b813..a00f0a7a 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"