Merge "Remove toolkit's jobs b/c it is archived"
[releng/builder.git] / jjb / include-raw-deploy-archives.sh
1 #!/bin/bash
2
3 set +e  # Do not affect the build result if some part of archiving fails.
4
5 ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
6 LOGS_SERVER="https://logs.opendaylight.org"
7 echo "Build logs: <a href=\"$LOGS_SERVER/$SILO/$ARCHIVES_DIR\">$LOGS_SERVER/$SILO/$ARCHIVES_DIR</a>"
8
9 mkdir .archives
10 cd .archives/
11
12 cat > deploy-archives.xml <<EOF
13 <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">
14   <modelVersion>4.0.0</modelVersion>
15   <groupId>logs</groupId>
16   <artifactId>logs</artifactId>
17   <version>1.0.0</version>
18   <packaging>pom</packaging>
19
20   <build>
21     <plugins>
22       <plugin>
23         <groupId>org.apache.maven.plugins</groupId>
24         <artifactId>maven-deploy-plugin</artifactId>
25         <version>2.8.2</version>
26         <configuration>
27           <skip>true</skip>
28         </configuration>
29       </plugin>
30       <plugin>
31         <groupId>org.sonatype.plugins</groupId>
32         <artifactId>maven-upload-plugin</artifactId>
33         <version>0.0.1</version>
34         <executions>
35           <execution>
36             <id>publish-site</id>
37             <phase>deploy</phase>
38             <goals>
39               <goal>upload-file</goal>
40             </goals>
41             <configuration>
42               <serverId>opendaylight-log-archives</serverId>
43               <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/logs/content-compressed</repositoryUrl>
44               <file>archives.zip</file>
45               <repositoryPath>$SILO</repositoryPath>
46             </configuration>
47           </execution>
48         </executions>
49       </plugin>
50     </plugins>
51   </build>
52 </project>
53 EOF
54
55 mkdir -p $ARCHIVES_DIR
56 mkdir -p $WORKSPACE/archives
57 if [ ! -z "${{ARCHIVE_ARTIFACTS}}" ]; then
58     pushd $WORKSPACE
59     shopt -s globstar  # Enable globstar to copy archives
60     archive_artifacts=$(echo ${{ARCHIVE_ARTIFACTS}})
61     for f in $archive_artifacts; do
62         echo "Archiving $f"
63         mkdir -p $WORKSPACE/archives/$(dirname $f)
64         mv $f $WORKSPACE/archives/$f
65     done
66     shopt -u globstar  # Disable globstar once archives are copied
67     popd
68 fi
69 # Ignore logging if archives doesn't exist
70 mv $WORKSPACE/archives/ $ARCHIVES_DIR > /dev/null 2>&1
71 touch $ARCHIVES_DIR/_build-details.txt
72 echo "build-url: ${{BUILD_URL}}" >> $ARCHIVES_DIR/_build-details.txt
73 env > $ARCHIVES_DIR/_build-enviroment-variables.txt
74
75 # Magic string used to trim console logs at the appropriate level during wget
76 echo "-----END_OF_BUILD-----"
77 wget -O $ARCHIVES_DIR/_console-output.log ${{BUILD_URL}}consoleText
78 sed -i '/^-----END_OF_BUILD-----$/,$d' $ARCHIVES_DIR/_console-output.log
79
80 gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log
81 # find and gzip any 'text' files
82 find $ARCHIVES_DIR -type f -print0 \
83                 | xargs -0r file \
84                 | egrep -e ':.*text.*' \
85                 | cut -d: -f1 \
86                 | xargs -d'\n' -r gzip
87
88 zip -r archives.zip $JENKINS_HOSTNAME/
89 du -sh archives.zip