Advertisement
jimklimov

Copy archived artifacts from child jobs

Mar 8th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | None | 0 0
  1. ### echo envvars
  2. #set
  3. #set -x
  4.  
  5. RES=0
  6. rm -rf archive archive.zip
  7. IFS="$IFS," ; for TJN in $TRIGGERED_JOB_NAMES ; do
  8.     # Assume each sub-job name is all dash-separated where this was escaped into underscores
  9.     # Note that dashes must not be part of shell var names, and that apparently MultiJob Phase behaves differently from simple Trigger build on other project
  10.     TAG="`echo "$TJN" | tr '-' '_' | tr '[a-z]' '[A-Z]'`"
  11.     JOB="`echo "$TJN" | tr '_' '-'`"
  12.     #VAR="TRIGGERED_BUILD_NUMBER_$TAG"
  13.     VAR="${TAG}_BUILD_NUMBER"
  14.     NUM="`eval echo '\$'$VAR`"
  15.     echo "=== Getting  XML artifacts from job '$JOB' build '$NUM'"
  16.  
  17.     rm -rf archive archive.zip
  18.     wget --no-check-certificate "${JENKINS_URL}/job/${JOB}/${NUM}/artifact/"'*zip*/archive.zip' \
  19.     || { echo "SKIP: no artifacts downloaded for job '$JOB' build '$NUM'" >&2 ; continue ; }
  20.  
  21.     unzip archive.zip \
  22.     || { echo "ERROR: could not unpack artifacts archive downloaded for job '$JOB' build '$NUM'" >&2 ; RES=42 ; continue ; }
  23.  
  24.     mv -f archive/*.xml . \
  25.     && echo "===== Remainder (if any):" && find archive -ls \
  26.     || { echo "SKIP: no XML artifacts were archived by job '$JOB' build '$NUM'" >&2 ; continue ; }
  27. done
  28.  
  29. rm -rf archive archive.zip
  30. [ "$RES" = 0 ] || echo "WARNING : At least one artifact-archive operation above ended badly" >&2
  31. exit $RES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement