3 set +e # Do not affect the build result if some part of archiving fails.
5 # Print out git status at the end of the build before we archive if $WORKSPACE
7 if [ -d $WORKSPACE/.git ]; then
9 echo "----------> Git Status Report"
14 echo "----------> Archiving build to logs server"
15 # Configure wget to not print download status when we download logs or when
16 # Jenkins is installing Maven (To be clear this is the Jenkins Maven plugin
17 # using a shell script itself that we are unable to modify directly to affect
19 echo "verbose=off" > ~/.wgetrc
21 ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
22 [ "$LOGS_SERVER" ] || LOGS_SERVER="https://logs.opendaylight.org"
23 [ "$LOGS_REPO_URL" ] || LOGS_REPO_URL="https://nexus.opendaylight.org/service/local/repositories/logs"
25 echo "Build logs: <a href=\"$LOGS_SERVER/$SILO/$ARCHIVES_DIR\">$LOGS_SERVER/$SILO/$ARCHIVES_DIR</a>"
30 cat > deploy-archives.xml <<EOF
31 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
32 <modelVersion>4.0.0</modelVersion>
33 <groupId>logs</groupId>
34 <artifactId>logs</artifactId>
35 <version>1.0.0</version>
36 <packaging>pom</packaging>
41 <groupId>org.apache.maven.plugins</groupId>
42 <artifactId>maven-deploy-plugin</artifactId>
43 <version>2.8.2</version>
49 <groupId>org.sonatype.plugins</groupId>
50 <artifactId>maven-upload-plugin</artifactId>
51 <version>0.0.1</version>
57 <goal>upload-file</goal>
60 <serverId>opendaylight-log-archives</serverId>
61 <repositoryUrl>$LOGS_REPO_URL/content-compressed</repositoryUrl>
62 <file>archives.zip</file>
63 <repositoryPath>$SILO</repositoryPath>
73 mkdir -p $ARCHIVES_DIR
74 mkdir -p $WORKSPACE/archives
75 if [ ! -z "${{ARCHIVE_ARTIFACTS}}" ]; then
77 shopt -s globstar # Enable globstar to copy archives
78 archive_artifacts=$(echo ${{ARCHIVE_ARTIFACTS}})
79 for f in $archive_artifacts; do
81 mkdir -p $WORKSPACE/archives/$(dirname $f)
82 mv $f $WORKSPACE/archives/$f
84 shopt -u globstar # Disable globstar once archives are copied
89 # Ignore logging if archives doesn't exist
90 mv $WORKSPACE/archives/ $ARCHIVES_DIR > /dev/null 2>&1
91 touch $ARCHIVES_DIR/_build-details.txt
92 echo "build-url: ${{BUILD_URL}}" >> $ARCHIVES_DIR/_build-details.txt
93 env | grep -v PASSWORD > $ARCHIVES_DIR/_build-enviroment-variables.txt
96 touch $ARCHIVES_DIR/_sys-info.txt
98 echo -e "uname -a:\n `uname -a` \n"
99 echo -e "df -h:\n `df -h` \n"
100 echo -e "free -m:\n `free -m` \n"
101 echo -e "nproc:\n `nproc` \n"
102 echo -e "lscpu:\n `lscpu` \n"
103 echo -e "ip addr:\n `/sbin/ip addr` \n"
104 }} 2>&1 | tee -a $ARCHIVES_DIR/_sys-info.txt
106 # Magic string used to trim console logs at the appropriate level during wget
107 echo "-----END_OF_BUILD-----"
108 wget -O $ARCHIVES_DIR/console.log ${{BUILD_URL}}consoleText
109 wget -O $ARCHIVES_DIR/console-timestamp.log "${{BUILD_URL}}/timestamps?time=HH:mm:ss&appendLog"
110 sed -i '/^-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/console.log
111 sed -i '/^.*-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/console-timestamp.log
113 gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log
114 # find and gzip any 'text' files
115 find $ARCHIVES_DIR -type f -print0 \
117 | egrep -e ':.*text.*' \
119 | xargs -d'\n' -r gzip
121 zip -r archives.zip $JENKINS_HOSTNAME/ > $ARCHIVES_DIR/_archives-zip.log