Add macro to deploy archives to Nexus
[releng/builder.git] / jjb / include-raw-deploy-archives.sh
1 #!/bin/bash
2 ARCHIVES_DIR="$JOB_NAME/`date +'%Y-%m-%d.%H%M%S'`-$BUILD_NUMBER-$BUILD_CAUSE"
3 LOGS_SERVER="https://logs.opendaylight.org"
4 echo "Build logs: <a href=\"$LOGS_SERVER/$SILO/$ARCHIVES_DIR\">$LOGS_SERVER/$SILO/$ARCHIVES_DIR</a>"
5
6 mkdir .archives
7 cd .archives/
8
9 cat > deploy-archives.xml <<EOF
10 <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">
11   <modelVersion>4.0.0</modelVersion>
12   <groupId>logs</groupId>
13   <artifactId>logs</artifactId>
14   <version>1.0.0</version>
15   <packaging>pom</packaging>
16
17   <build>
18     <plugins>
19       <plugin>
20         <groupId>org.apache.maven.plugins</groupId>
21         <artifactId>maven-deploy-plugin</artifactId>
22         <version>2.8.2</version>
23         <configuration>
24           <skip>true</skip>
25         </configuration>
26       </plugin>
27       <plugin>
28         <groupId>org.sonatype.plugins</groupId>
29         <artifactId>maven-upload-plugin</artifactId>
30         <version>0.0.1</version>
31         <executions>
32           <execution>
33             <id>publish-site</id>
34             <phase>deploy</phase>
35             <goals>
36               <goal>upload-file</goal>
37             </goals>
38             <configuration>
39               <serverId>opendaylight-log-archives</serverId>
40               <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/logs/content-compressed</repositoryUrl>
41               <file>archives.zip</file>
42               <repositoryPath>$SILO</repositoryPath>
43             </configuration>
44           </execution>
45         </executions>
46       </plugin>
47     </plugins>
48   </build>
49 </project>
50 EOF
51
52 mkdir -p $ARCHIVES_DIR
53 mv $WORKSPACE/archives/ $ARCHIVES_DIR
54 touch $ARCHIVES_DIR/_build-details.txt
55 echo "build-url: ${{BUILD_URL}}" >> $ARCHIVES_DIR/_build-details.txt
56 wget -O $ARCHIVES_DIR/_console-output.log ${{BUILD_URL}}consoleText
57 gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log
58 # find and gzip all text files
59 find $ARCHIVES_DIR -name "*.txt" \
60                 -o -name "*.log" \
61                 -o -name "*.html" \
62                 | xargs gzip
63
64 zip -r archives.zip $JOB_NAME/
65
66 # Notify Gerrit where logs are located
67 if [ -n "$GERRIT_PATCHSET_REVISION" ]; then
68     LOG_MESSAGE="Logs located at https://nexus.opendaylight.org/content/sites/logs/$SILO/$ARCHIVES_DIR/"
69     ssh -p 29418 git.opendaylight.org gerrit review -m "$LOG_MESSAGE" $GERRIT_PATCHSET_REVISION
70 fi