Merge "Improve archive-build macro to gzip any text file"
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 13 Jul 2016 15:28:08 +0000 (15:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 13 Jul 2016 15:28:08 +0000 (15:28 +0000)
1  2 
jjb/include-raw-deploy-archives.sh

index 56a77eaea65a6f25943cbc5d05d46542f5715a35,22707c1e3ee1759df01f2e86a49c7b4b18b06955..79a86d5ac0b474c0d343e9ccbcbf971614c9c0b9
@@@ -50,19 -50,6 +50,19 @@@ cat > deploy-archives.xml <<EO
  EOF
  
  mkdir -p $ARCHIVES_DIR
 +mkdir -p $WORKSPACE/archives
 +if [ ! -z $ARCHIVE_ARTIFACTS ]; then
 +    pushd $WORKSPACE
 +    shopt -s globstar  # Enable globstar to copy archives
 +    archive_artifacts=$(echo $ARCHIVE_ARTIFACTS)
 +    for f in $archive_artifacts; do
 +        echo "Archiving $f"
 +        mkdir -p $WORKSPACE/archives/$(dirname $f)
 +        mv $f $WORKSPACE/archives/$f
 +    done
 +    shopt -u globstar  # Disable globstar once archives are copied
 +    popd
 +fi
  # Ignore logging if archives doesn't exist
  mv $WORKSPACE/archives/ $ARCHIVES_DIR > /dev/null 2>&1
  touch $ARCHIVES_DIR/_build-details.txt
@@@ -75,11 -62,12 +75,12 @@@ wget -O $ARCHIVES_DIR/_console-output.l
  sed -i '/^-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/_console-output.log
  
  gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log
- # find and gzip all text files
- find $ARCHIVES_DIR -name "*.txt" \
-                 -o -name "*.log" \
-                 -o -name "*.html" \
-                 | xargs gzip
+ # find and gzip any 'text' files
+ find $ARCHIVES_DIR -type f -print0 \
+                 | xargs -0r file \
+                 | egrep -e ':.*text.*' \
+                 | cut -d: -f1 \
+                 | xargs -d'\n' -r gzip
  
  zip -r archives.zip $JENKINS_HOSTNAME/
  du -sh archives.zip