fix: add building static vppctl as part of the CI for VPP
[ci-management.git] / jjb / scripts / post_build_deploy_archives.sh
index b7e7cec..a332f21 100755 (executable)
@@ -19,19 +19,9 @@ set +e  # Do not affect the build result if some part of archiving fails.
 WS_ARCHIVES_DIR="$WORKSPACE/archives"
 BUILD_ENV_LOG="$WS_ARCHIVES_DIR/_build-enviroment-variables.log"
 
-# Output executor runtime attributes [again] in case the job fails prior to
-# running setup_executor_env.sh
-long_line="************************************************************************"
-OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-OS_ARCH=$(uname -m)
-echo "$long_line"
-echo "Executor Runtime Attributes:"
-echo "OS: $OS_ID-$OS_VERSION_ID"
-echo "Arch: $OS_ARCH"
-echo "Nomad Hostname: $(grep search /etc/resolv.conf | cut -d' ' -f2 | head -1)"
-echo "Container ID: $(hostname)"
-echo "$long_line"
+if curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"; then
+    unzip -d ./archives robot-plugin.zip
+fi
 
 # Generate gdb-command script to output vpp stack traceback from core files.
 gdb_cmdfile="/tmp/gdb-commands"
@@ -62,6 +52,9 @@ STACKTRACE=""
 # Returns stacktrace filename in STACKTRACE
 generate_vpp_stacktrace_and_delete_core() {
     local corefile="$1"
+    echo "Uncompressing core file $file"
+    gunzip "$corefile"
+    corefile="${corefile::(-3)}"
     if grep -qe 'debug' <<< "$WORKSPACE" ; then
         local binfile="$WORKSPACE/build-root/install-vpp_debug-native/vpp/bin/vpp"
     else
@@ -75,66 +68,26 @@ generate_vpp_stacktrace_and_delete_core() {
     echo "Removing core file: $corefile"
     rm -f "$corefile"
     # Dump stacktrace to console log
-    if [ -f $STACKTRACE ] ; then
+    if [ -f "$STACKTRACE" ] ; then
         echo -e "\n=====[ $STACKTRACE ]=====\n$(cat $STACKTRACE)\n=====[ $STACKTRACE ]=====\n"
+        gzip "$STACKTRACE"
     else
         echo "Stacktrace file not generated!"
         STACKTRACE=""
     fi
 }
 
-# Delete existing archives dir to ensure current artifact upload
-rm -rf "$WS_ARCHIVES_DIR"
 mkdir -p "$WS_ARCHIVES_DIR"
 
-# Log the build environment variables
-echo "Logging build environment variables in '$BUILD_ENV_LOG'..."
-env > $BUILD_ENV_LOG
-
-echo "WS_ARCHIVE_ARTIFACTS = '$WS_ARCHIVE_ARTIFACTS'"
-if [ -n "${WS_ARCHIVE_ARTIFACTS}" ]; then
-    pushd $WORKSPACE
-    shopt -s globstar  # Enable globstar to copy archives
-    archive_artifacts=$(echo ${WS_ARCHIVE_ARTIFACTS})
-    shopt -u globstar  # Disable globstar
-    for file in $archive_artifacts; do
-        if [ -f "$file" ] ; then
-            fname="$(basename $file)"
-            # Decompress core.gz file
-            if grep -qe '^core.*\.gz$' <<<"$fname" ; then
-                echo "Uncompressing core file $file"
-                gunzip "$file"
-                file="${file::(-3)}"
-            fi
-            # Convert core file to stacktrace
-            if [ "${fname::4}" = "core" ] ; then
-                generate_vpp_stacktrace_and_delete_core $file
-                [ -z "$STACKTRACE" ] && continue
-                file=$STACKTRACE
-            fi
-            # Set destination filename
-            if [ "${file::26}" = "/tmp/vpp-failed-unittests/" ] ; then
-                destfile=$WS_ARCHIVES_DIR${file:25}
-            else
-                destfile=$WS_ARCHIVE_DIR$file
-            fi
-            echo "Archiving '$file' to '$destfile'"
-            destdir="$(dirname $destfile)"
-            mkdir -p $destdir
-            mv $file $destfile
-        else
-            echo "Not archiving '$file'"
-        fi
+# generate stack trace for VPP core files for upload instead of core file.
+if [ -d "$WORKSPACE/build-root" ] ; then
+    for file in $(find $WS_ARCHIVES_DIR -type f -name 'core*.gz') ; do
+        generate_vpp_stacktrace_and_delete_core $file
     done
-    popd
 fi
 
-# find and gzip any 'text' files
-find $WS_ARCHIVES_DIR -type f -print0 \
-                | xargs -0r file \
-                | egrep -e ':.*text.*' \
-                | cut -d: -f1 \
-                | xargs -d'\n' -r gzip
+# Remove any socket files in archive
+find $WS_ARCHIVES_DIR -type s -exec rm -rf {} \;
 
 echo "Workspace archived artifacts:"
 ls -alR $WS_ARCHIVES_DIR