Save distribution in distribution-check job
[releng/builder.git] / jjb / include-raw-deploy-archives.sh
index 56a77eaea65a6f25943cbc5d05d46542f5715a35..ef446712c4d4b36f97a7b2aa0b762035c9df3e26 100644 (file)
@@ -1,6 +1,11 @@
 #!/bin/bash
+
+set +e  # Do not affect the build result if some part of archiving fails.
+
 ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
-LOGS_SERVER="https://logs.opendaylight.org"
+[ "$LOGS_SERVER" ] || LOGS_SERVER="https://logs.opendaylight.org"
+[ "$LOGS_REPO_URL" ] || LOGS_REPO_URL="https://nexus.opendaylight.org/service/local/repositories/logs"
+
 echo "Build logs: <a href=\"$LOGS_SERVER/$SILO/$ARCHIVES_DIR\">$LOGS_SERVER/$SILO/$ARCHIVES_DIR</a>"
 
 mkdir .archives
@@ -37,7 +42,7 @@ cat > deploy-archives.xml <<EOF
             </goals>
             <configuration>
               <serverId>opendaylight-log-archives</serverId>
-              <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/logs/content-compressed</repositoryUrl>
+              <repositoryUrl>$LOGS_REPO_URL/content-compressed</repositoryUrl>
               <file>archives.zip</file>
               <repositoryPath>$SILO</repositoryPath>
             </configuration>
@@ -51,10 +56,10 @@ EOF
 
 mkdir -p $ARCHIVES_DIR
 mkdir -p $WORKSPACE/archives
-if [ ! -z $ARCHIVE_ARTIFACTS ]; then
+if [ ! -z "${{ARCHIVE_ARTIFACTS}}" ]; then
     pushd $WORKSPACE
     shopt -s globstar  # Enable globstar to copy archives
-    archive_artifacts=$(echo $ARCHIVE_ARTIFACTS)
+    archive_artifacts=$(echo ${{ARCHIVE_ARTIFACTS}})
     for f in $archive_artifacts; do
         echo "Archiving $f"
         mkdir -p $WORKSPACE/archives/$(dirname $f)
@@ -75,11 +80,12 @@ wget -O $ARCHIVES_DIR/_console-output.log ${{BUILD_URL}}consoleText
 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