From d831bb45209476c83aa5c138079680d32ac95d88 Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Thu, 6 Apr 2017 10:31:52 -0700 Subject: Port in log shipping changes from OpenDaylight Fix the log shipping script to be directed to ONAP instead of Open-O which is where it was initially pulled from. Additionally, update to the latest changes that OpenDaylight is using. Change-Id: I78a950dd6451ed0a77ac2f157bd4de4e620c6187 Signed-off-by: Andrew Grimberg --- jjb/include-raw-deploy-archives.sh | 85 +++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 33 deletions(-) (limited to 'jjb') diff --git a/jjb/include-raw-deploy-archives.sh b/jjb/include-raw-deploy-archives.sh index 8f63b0e2f..4d0945aa6 100644 --- a/jjb/include-raw-deploy-archives.sh +++ b/jjb/include-raw-deploy-archives.sh @@ -2,14 +2,30 @@ set +e # Do not affect the build result if some part of archiving fails. +# Print out git status at the end of the build before we archive if $WORKSPACE +# is a git repo. +if [ -d "$WORKSPACE/.git" ]; then + echo "" + echo "----------> Git Status Report" + git status +fi + +echo "" +echo "----------> Archiving build to logs server" +# Configure wget to not print download status when we download logs or when +# Jenkins is installing Maven (To be clear this is the Jenkins Maven plugin +# using a shell script itself that we are unable to modify directly to affect +# wget). +echo "verbose=off" > ~/.wgetrc + ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER" -[ "$LOGS_SERVER" ] || LOGS_SERVER="https://logs.open-o.org" -[ "$LOGS_REPO_URL" ] || LOGS_REPO_URL="https://nexus.open-o.org/service/local/repositories/logs" +[ "$LOGS_SERVER" ] || LOGS_SERVER="https://logs.onap.org" +[ "$LOGS_REPO_URL" ] || LOGS_REPO_URL="https://nexus.onap.org/service/local/repositories/logs" echo "Build logs: $LOGS_SERVER/$SILO/$ARCHIVES_DIR" mkdir .archives -cd .archives/ +cd .archives/ || exit 1 cat > deploy-archives.xml < @@ -41,7 +57,7 @@ cat > deploy-archives.xml <upload-file - open-o-log-archives + onap-log-archives $LOGS_REPO_URL/content-compressed archives.zip $SILO @@ -54,16 +70,17 @@ cat > deploy-archives.xml < EOF -mkdir -p $ARCHIVES_DIR -mkdir -p $WORKSPACE/archives -if [ ! -z "${ARCHIVE_ARTIFACTS}" ]; then - pushd $WORKSPACE +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 + for f in $ARCHIVE_ARTIFACTS; do + [[ -e $f ]] || continue # handle the case of no files to archive + echo "Archiving $f" >> "$WORKSPACE/.archives/$ARCHIVES_DIR/_archives.log" + dir=$(dirname "$f") + mkdir -p "$WORKSPACE/archives/$dir" + mv "$f" "$WORKSPACE/archives/$f" done shopt -u globstar # Disable globstar once archives are copied popd @@ -71,36 +88,38 @@ fi # Ignore logging if archives doesn't exist -mv $WORKSPACE/archives/ $ARCHIVES_DIR > /dev/null 2>&1 -touch $ARCHIVES_DIR/_build-details.txt -echo "build-url: ${BUILD_URL}" >> $ARCHIVES_DIR/_build-details.txt -env > $ARCHIVES_DIR/_build-enviroment-variables.txt +mv "$WORKSPACE/archives/" "$ARCHIVES_DIR" > /dev/null 2>&1 +touch "$ARCHIVES_DIR/_build-details.txt" +echo "build-url: ${BUILD_URL}" >> "$ARCHIVES_DIR/_build-details.txt" +env | grep -v PASSWORD > "$ARCHIVES_DIR/_build-enviroment-variables.txt" # capture system info -touch $ARCHIVES_DIR/_sys-info.txt -{{ - echo -e "uname -a:\n `uname -a` \n" - echo -e "df -h:\n `df -h` \n" - echo -e "free -m:\n `free -m` \n" - echo -e "nproc:\n `nproc` \n" - echo -e "lscpu:\n `lscpu` \n" - echo -e "ip addr:\n `/sbin/ip addr` \n" -}} 2>&1 | tee -a $ARCHIVES_DIR/_sys-info.txt +touch "$ARCHIVES_DIR/_sys-info.txt" +{ + echo -e "uname -a:\n $(uname -a) \n" + echo -e "df -h:\n $(df -h) \n" + echo -e "free -m:\n $(free -m) \n" + echo -e "nproc:\n $(nproc) \n" + echo -e "lscpu:\n $(lscpu) \n" + echo -e "ip addr:\n $(/sbin/ip addr) \n" +} 2>&1 | tee -a "$ARCHIVES_DIR/_sys-info.txt" # Magic string used to trim console logs at the appropriate level during wget echo "-----END_OF_BUILD-----" -wget -O $ARCHIVES_DIR/console.log ${BUILD_URL}consoleText -wget -O $ARCHIVES_DIR/console-timestamp.log ${BUILD_URL}/timestamps?time=HH:mm:ss\&appendLog -sed -i '/^-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/console.log -sed -i '/^.*-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/console-timestamp.log +wget -O "$ARCHIVES_DIR/console.log" "${BUILD_URL}consoleText" +wget -O "$ARCHIVES_DIR/console-timestamp.log" "$BUILD_URL/timestamps?time=HH:mm:ss&appendLog" +sed -i '/^-----END_OF_BUILD-----$/,$d' "$ARCHIVES_DIR/console.log" +sed -i '/^.*-----END_OF_BUILD-----$/,$d' "$ARCHIVES_DIR/console-timestamp.log" -gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log +gzip "$ARCHIVES_DIR"/*.txt "$ARCHIVES_DIR"/*.log # find and gzip any 'text' files -find $ARCHIVES_DIR -type f -print0 \ +find "$ARCHIVES_DIR" -type f -print0 \ | xargs -0r file \ | egrep -e ':.*text.*' \ | cut -d: -f1 \ | xargs -d'\n' -r gzip +# Compress Java heap dumps using xz +find "$ARCHIVES_DIR" -type f -name \*.hprof -print0 | xargs -0 xz -zip -r archives.zip $JENKINS_HOSTNAME/ +zip -r archives.zip "$JENKINS_HOSTNAME/" >> "$ARCHIVES_DIR/_archives.log" du -sh archives.zip -- cgit 1.2.3-korg