Add macro to deploy archives to Nexus 12/40212/7
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 13 Jun 2016 04:05:35 +0000 (00:05 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 20 Jun 2016 21:20:57 +0000 (17:20 -0400)
Requires the Description Setter plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin

Change-Id: Ibc3d4a74416995b699e420864626dabd8a3c0658
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/include-raw-deploy-archives.sh [new file with mode: 0644]
jjb/releng-macros.yaml

diff --git a/jjb/include-raw-deploy-archives.sh b/jjb/include-raw-deploy-archives.sh
new file mode 100644 (file)
index 0000000..8fe112c
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash
+ARCHIVES_DIR="$JOB_NAME/`date +'%Y-%m-%d.%H%M%S'`-$BUILD_NUMBER-$BUILD_CAUSE"
+LOGS_SERVER="https://logs.opendaylight.org"
+echo "Build logs: <a href=\"$LOGS_SERVER/$SILO/$ARCHIVES_DIR\">$LOGS_SERVER/$SILO/$ARCHIVES_DIR</a>"
+
+mkdir .archives
+cd .archives/
+
+cat > deploy-archives.xml <<EOF
+<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">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>logs</groupId>
+  <artifactId>logs</artifactId>
+  <version>1.0.0</version>
+  <packaging>pom</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>2.8.2</version>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.sonatype.plugins</groupId>
+        <artifactId>maven-upload-plugin</artifactId>
+        <version>0.0.1</version>
+        <executions>
+          <execution>
+            <id>publish-site</id>
+            <phase>deploy</phase>
+            <goals>
+              <goal>upload-file</goal>
+            </goals>
+            <configuration>
+              <serverId>opendaylight-log-archives</serverId>
+              <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/logs/content-compressed</repositoryUrl>
+              <file>archives.zip</file>
+              <repositoryPath>$SILO</repositoryPath>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
+EOF
+
+mkdir -p $ARCHIVES_DIR
+mv $WORKSPACE/archives/ $ARCHIVES_DIR
+touch $ARCHIVES_DIR/_build-details.txt
+echo "build-url: ${{BUILD_URL}}" >> $ARCHIVES_DIR/_build-details.txt
+wget -O $ARCHIVES_DIR/_console-output.log ${{BUILD_URL}}consoleText
+gzip $ARCHIVES_DIR/*.txt $ARCHIVES_DIR/*.log
+# find and gzip all text files
+find $ARCHIVES_DIR -name "*.txt" \
+                -o -name "*.log" \
+                -o -name "*.html" \
+                | xargs gzip
+
+zip -r archives.zip $JOB_NAME/
+
+# Notify Gerrit where logs are located
+if [ -n "$GERRIT_PATCHSET_REVISION" ]; then
+    LOG_MESSAGE="Logs located at https://nexus.opendaylight.org/content/sites/logs/$SILO/$ARCHIVES_DIR/"
+    ssh -p 29418 git.opendaylight.org gerrit review -m "$LOG_MESSAGE" $GERRIT_PATCHSET_REVISION
+fi
index d5e9cc6be7c97a2a1918464a5ba729864025f35f..4bc59d742030f23eb9a0ee5b98374cbd446c49ae 100644 (file)
                       healthy: 50
                       unhealthy: 40
 
+- publisher:
+    name: archive-build
+    # To archive things the job will need to create a "archives" directory in
+    # the workspace and this macro will handle copying the contents of the
+    # archives directory.
+    publishers:
+        - postbuildscript:
+            builders:
+                - shell: !include-raw: include-raw-deploy-archives.sh
+                - maven-target:
+                        maven-version: '{maven-version}'
+                        pom: '.archives/deploy-archives.xml'
+                        goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
+                        settings: 'jenkins-log-archives-settings'
+                        settings-type: cfp
+                        global-settings: 'odl-global-settings'
+                        global-settings-type: cfp
+                - description-setter:
+                    regexp: '^Build logs: .*'
+            script-only-if-succeeded: False
+            script-only-if-failed: False
+            mark-unstable-if-failed: True
+
 - builder:
     name: wipe-org-opendaylight-repo
     builders: