Add job type to publish a zipped p2repo to Nexus Site
[releng/builder.git] / jjb / include-raw-update-p2composite-metadata.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2016 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 EPOCH_DATE=`date +%s%3N`
13 MVN_METADATA=`echo $P2ZIP_URL | sed 's,/*[^/]\+/*$,,' | sed 's,/*[^/]\+/*$,,'`/maven-metadata.xml
14 P2_COMPOSITE_ARTIFACTS=compositeArtifacts.xml
15 P2_COMPOSITE_CONTENT=compositeContent.xml
16
17 wget $MVN_METADATA -O maven-metadata.xml
18
19 VERSIONS=`xmlstarlet sel -t -m "/metadata/versioning/versions" -v "version" maven-metadata.xml`
20 NUM_VERSIONS=`echo $VERSIONS | wc -w`
21
22
23 ##
24 ## Create compositeArtifacts.xml and compositeContent.xml files
25 ##
26
27 cat > $P2_COMPOSITE_ARTIFACTS <<EOF
28 <?xml version='1.0' encoding='UTF-8'?>
29 <?compositeArtifactRepository version='1.0.0'?>
30 <repository name='OpenDaylight $PROJECT'
31     type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository' version='1.0.0'>
32   <properties size='1'>
33     <property name='p2.timestamp' value='$EPOCH_DATE'/>
34   </properties>
35   <children size='$NUM_VERSIONS'>
36 EOF
37
38 cat > $P2_COMPOSITE_CONTENT <<EOF
39 <?xml version='1.0' encoding='UTF-8'?>
40 <?compositeMetadataRepository version='1.0.0'?>
41 <repository name='OpenDaylight $PROJECT'
42     type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository' version='1.0.0'>
43   <properties size='1'>
44     <property name='p2.timestamp' value='$EPOCH_DATE'/>
45   </properties>
46   <children size='$NUM_VERSIONS'>
47 EOF
48
49 ##
50 ## Loop versions
51 ##
52
53 for ver in $VERSIONS
54 do
55     echo "    <child location='$ver'/>" >> $P2_COMPOSITE_ARTIFACTS
56     echo "    <child location='$ver'/>" >> $P2_COMPOSITE_CONTENT
57 done
58
59 ##
60 ## Close files
61 ##
62
63 cat >> $P2_COMPOSITE_ARTIFACTS <<EOF
64   </children>
65 </repository>
66 EOF
67
68 cat >> $P2_COMPOSITE_CONTENT <<EOF
69   </children>
70 </repository>
71 EOF
72
73 ##
74 ## Create poms for uploading
75 ##
76
77 zip composite-repo.zip $P2_COMPOSITE_ARTIFACTS $P2_COMPOSITE_CONTENT
78
79 cat > deploy-composite-repo.xml <<EOF
80 <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">
81   <modelVersion>4.0.0</modelVersion>
82   <groupId>org.opendaylight.$PROJECT</groupId>
83   <artifactId>p2repo</artifactId>
84   <version>1.0.0-SNAPSHOT</version>
85   <packaging>pom</packaging>
86
87   <build>
88     <plugins>
89       <plugin>
90         <groupId>org.apache.maven.plugins</groupId>
91         <artifactId>maven-deploy-plugin</artifactId>
92         <version>2.8.2</version>
93         <configuration>
94           <skip>true</skip>
95         </configuration>
96       </plugin>
97       <plugin>
98         <groupId>org.sonatype.plugins</groupId>
99         <artifactId>maven-upload-plugin</artifactId>
100         <version>0.0.1</version>
101         <executions>
102           <execution>
103             <id>publish-site</id>
104             <phase>deploy</phase>
105             <goals>
106               <goal>upload-file</goal>
107             </goals>
108             <configuration>
109               <serverId>opendaylight-p2</serverId>
110               <repositoryUrl>https://nexus.opendaylight.org/service/local/repositories/p2repos/content-compressed</repositoryUrl>
111               <file>composite-repo.zip</file>
112               <repositoryPath>org.opendaylight.$PROJECT</repositoryPath>
113             </configuration>
114           </execution>
115         </executions>
116       </plugin>
117     </plugins>
118   </build>
119 </project>
120 EOF