3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 echo "---> jjb/scripts/post_build_deploy_archives.sh"
18 set +e # Do not affect the build result if some part of archiving fails.
19 WS_ARCHIVES_DIR="$WORKSPACE/archives"
20 BUILD_ENV_LOG="$WS_ARCHIVES_DIR/_build-enviroment-variables.log"
22 if curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"; then
23 unzip -d ./archives robot-plugin.zip
26 # Generate gdb-command script to output vpp stack traceback from core files.
27 gdb_cmdfile="/tmp/gdb-commands"
28 cat >$gdb_cmdfile <<'__END__'
30 # gdb $BINFILE $CORE -ex 'source -v gdb-commands' -ex quit
45 thread apply all printstack
52 # Returns stacktrace filename in STACKTRACE
53 generate_vpp_stacktrace_and_delete_core() {
55 echo "Uncompressing core file $file"
57 corefile="${corefile::(-3)}"
58 if grep -qe 'debug' <<< "$WORKSPACE" ; then
59 local binfile="$WORKSPACE/build-root/install-vpp_debug-native/vpp/bin/vpp"
61 local binfile="$WORKSPACE/build-root/install-vpp-native/vpp/bin/vpp"
64 echo "Generating stack trace from core file: $corefile"
65 STACKTRACE="${corefile}.stacktrace"
66 gdb "$binfile" $corefile -ex 'source -v /tmp/gdb-commands' -ex quit > $STACKTRACE
67 # remove the core to save space
68 echo "Removing core file: $corefile"
70 # Dump stacktrace to console log
71 if [ -f "$STACKTRACE" ] ; then
72 echo -e "\n=====[ $STACKTRACE ]=====\n$(cat $STACKTRACE)\n=====[ $STACKTRACE ]=====\n"
75 echo "Stacktrace file not generated!"
80 mkdir -p "$WS_ARCHIVES_DIR"
82 # generate stack trace for VPP core files for upload instead of core file.
83 if [ -d "$WORKSPACE/build-root" ] ; then
84 for file in $(find $WS_ARCHIVES_DIR -type f -name 'core*.gz') ; do
85 generate_vpp_stacktrace_and_delete_core $file
89 # Remove any socket files in archive
90 find $WS_ARCHIVES_DIR -type s -exec rm -rf {} \;
92 echo "Workspace archived artifacts:"
93 ls -alR $WS_ARCHIVES_DIR