Add job type to publish a zipped p2repo to Nexus Site 36/37936/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 20 Apr 2016 18:11:47 +0000 (14:11 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 20 Apr 2016 20:42:26 +0000 (16:42 -0400)
This job pushes a zipped p2repo (preferrabled from staging repo that's
about to be released) to Nexus Site repo under 'p2repos'.

Change-Id: Iaa349e67194df650e9db6e245931ea544ae53af9
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/include-raw-generate-p2pom.sh [new file with mode: 0644]
jjb/include-raw-update-p2composite-metadata.sh [new file with mode: 0644]
jjb/releng-macros.yaml
jjb/releng-templates.yaml
jjb/yangide/yangide-releng.yaml

diff --git a/jjb/include-raw-generate-p2pom.sh b/jjb/include-raw-generate-p2pom.sh
new file mode 100644 (file)
index 0000000..5e5ffde
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+FILE_NAME=`echo $P2ZIP_URL | awk -F'/' '{ print $NF }'`
+VERSION=`echo $P2ZIP_URL | awk -F'/' '{ print $(NF-1) }'`
+
+wget $P2ZIP_URL -O $FILE_NAME
+
+cat > ${WORKSPACE}/pom.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>org.opendaylight.$PROJECT</groupId>
+  <artifactId>p2repo</artifactId>
+  <version>1.0.0-SNAPSHOT</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-p2</serverId>
+              <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/p2repos/content-compressed</repositoryUrl>
+              <file>$FILE_NAME</file>
+              <repositoryPath>org.opendaylight.$PROJECT/$VERSION</repositoryPath>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
+EOF
diff --git a/jjb/include-raw-update-p2composite-metadata.sh b/jjb/include-raw-update-p2composite-metadata.sh
new file mode 100644 (file)
index 0000000..f4223af
--- /dev/null
@@ -0,0 +1,120 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+EPOCH_DATE=`date +%s%3N`
+MVN_METADATA=`echo $P2ZIP_URL | sed 's,/*[^/]\+/*$,,' | sed 's,/*[^/]\+/*$,,'`/maven-metadata.xml
+P2_COMPOSITE_ARTIFACTS=compositeArtifacts.xml
+P2_COMPOSITE_CONTENT=compositeContent.xml
+
+wget $MVN_METADATA -O maven-metadata.xml
+
+VERSIONS=`xmlstarlet sel -t -m "/metadata/versioning/versions" -v "version" maven-metadata.xml`
+NUM_VERSIONS=`echo $VERSIONS | wc -w`
+
+
+##
+## Create compositeArtifacts.xml and compositeContent.xml files
+##
+
+cat > $P2_COMPOSITE_ARTIFACTS <<EOF
+<?xml version='1.0' encoding='UTF-8'?>
+<?compositeArtifactRepository version='1.0.0'?>
+<repository name='OpenDaylight $PROJECT'
+    type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository' version='1.0.0'>
+  <properties size='1'>
+    <property name='p2.timestamp' value='$EPOCH_DATE'/>
+  </properties>
+  <children size='$NUM_VERSIONS'>
+EOF
+
+cat > $P2_COMPOSITE_CONTENT <<EOF
+<?xml version='1.0' encoding='UTF-8'?>
+<?compositeMetadataRepository version='1.0.0'?>
+<repository name='OpenDaylight $PROJECT'
+    type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository' version='1.0.0'>
+  <properties size='1'>
+    <property name='p2.timestamp' value='$EPOCH_DATE'/>
+  </properties>
+  <children size='$NUM_VERSIONS'>
+EOF
+
+##
+## Loop versions
+##
+
+for ver in $VERSIONS
+do
+    echo "    <child location='$ver'/>" >> $P2_COMPOSITE_ARTIFACTS
+    echo "    <child location='$ver'/>" >> $P2_COMPOSITE_CONTENT
+done
+
+##
+## Close files
+##
+
+cat >> $P2_COMPOSITE_ARTIFACTS <<EOF
+  </children>
+</repository>
+EOF
+
+cat >> $P2_COMPOSITE_CONTENT <<EOF
+  </children>
+</repository>
+EOF
+
+##
+## Create poms for uploading
+##
+
+zip composite-repo.zip $P2_COMPOSITE_ARTIFACTS $P2_COMPOSITE_CONTENT
+
+cat > deploy-composite-repo.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>org.opendaylight.$PROJECT</groupId>
+  <artifactId>p2repo</artifactId>
+  <version>1.0.0-SNAPSHOT</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-p2</serverId>
+              <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/p2repos/content-compressed</repositoryUrl>
+              <file>composite-repo.zip</file>
+              <repositoryPath>org.opendaylight.$PROJECT</repositoryPath>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
+EOF
index 97d13d9ec7a9068e07db1be5c78f6e8b99a52a97..4238aa26fb147cad41653b95a489de7e6d2f3cbc 100644 (file)
             default: 'master'
             description: 'distribution repo branch to build with'
 
+- parameter:
+    name: p2zip-parameter
+    parameters:
+        - string:
+            name: P2ZIP_URL
+            default: ''
+            description: 'Nexus staging profile id'
+
 - parameter:
     name: stage-id-parameter
     parameters:
         - file-id: '{settings-file}'
           variable: 'SETTINGS_FILE'
 
+- builder:
+    name: releng-generate-p2pom
+    builders:
+        - shell: !include-raw: include-raw-generate-p2pom.sh
+
+- builder:
+    name: releng-update-p2composite-metadata
+    builders:
+    - shell: !include-raw: include-raw-update-p2composite-metadata.sh
+    - maven-target:
+        maven-version: '{maven-version}'
+        pom: 'deploy-composite-repo.xml'
+        goals: 'clean deploy -V -Dmaven.repo.local=/tmp/r'
+        settings: '{settings}'
+        global-settings: '{global-settings}'
+
 - builder:
     name: releng-stage-release
     builders:
index a90aec478c532fb77ff9005b60487c18cf6f84e7..be6ddc73dac70f8bcdd9c538553096e0e74cfacf 100644 (file)
         - email-notification:
             email-prefix: '[releng]'
 
+
+- job-template:
+    name: '{name}-publish-p2repo'
+
+    # Job template for publishing a p2 repo given a URL to a zipped p2repo.
+
+    project-type: maven
+    node: dynamic_merge
+    jdk: '{jdk}'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - p2zip-parameter
+
+    prebuilders:
+        - wipe-org-opendaylight-repo
+        - jacoco-nojava-workaround
+        - releng-generate-p2pom
+
+    maven:
+        maven-name: '{mvn33}'
+        root-pom: 'pom.xml'
+        goals: 'clean deploy -V -Dmaven.repo.local=/tmp/r'
+        settings: '{project-settings}'
+        global-settings: '{odl-global-settings}'
+        post-step-run-condition: UNSTABLE
+
+    postbuilders:
+        - releng-update-p2composite-metadata:
+            maven-version: '{mvn33}'
+            settings: '{project-settings}'
+            global-settings: '{odl-global-settings}'
+
+    publishers:
+        - email-notification:
+            email-prefix: '[releng]'
+
 - job-template:
     name: '{name}-verify-python-{stream}'
 
index 19d3f7e7748c97288048b601ae257e0c9fb1fcbb..45e19b69ece705ceff3aa346fae2ea6d5afd3f97 100644 (file)
@@ -1,8 +1,10 @@
 - project:
     name: yangide-releng
     jobs:
+    - '{name}-publish-p2repo'
     - '{name}-release-java'
 
     project: yangide
     jdk: 'openjdk8'
     stage-id: 'fba306956f98'
+    project-settings: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1448465159080'