1 # create a fresh empty place to build this custom distribution
2 BUILD_DIR=${WORKSPACE}/patch_tester
3 POM_FILE=${WORKSPACE}/patch_tester/pom.xml
4 DISTRIBUTION_BRANCH_TO_BUILD=$BRANCH #renaming variable for clarity
10 # create a root pom that will contain a module for each project we have a patch for
11 echo "<project>" >> $POM_FILE
12 echo "<groupId>org.opendaylight.test</groupId>" >> $POM_FILE
13 echo "<artifactId>test</artifactId>" >> $POM_FILE
14 echo "<version>0.1</version>" >> $POM_FILE
15 echo "<modelVersion>4.0.0</modelVersion>" >> $POM_FILE
16 echo "<packaging>pom</packaging>" >> $POM_FILE
17 echo "<modules>" >> $POM_FILE
19 IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}"
21 # for each patch, clone the project, and fetch/checkout the patch set.
22 # each patch is found in the ${PATCHES_TO_BUILD} variable as a comma
23 # separated list of project:changeset values
24 # Example: PATCHES_TO_BUILD=snmp:97/27997/1,tcpmd5:91/26391/3
26 # TODO: this version will not handle multiple patches from the same project and will be
27 # done at a later time. cherry-picking will be needed, with more complex logic
29 distribution_status="not_patched"
30 for i in "${PATCHES[@]}"
32 echo "working on ${i}"
33 PROJECT=`echo ${i} | cut -d\: -f 1`
34 if [ "${PROJECT}" == "integration/distribution" ]; then
35 distribution_status="patched"
37 PROJECT_SHORTNAME="${PROJECT##*/}" # http://stackoverflow.com/a/3162500
38 PATCH=`echo ${i} | cut -d\: -f 2`
39 echo "<module>${PROJECT_SHORTNAME}</module>" >> $POM_FILE
40 echo "cloning ${PROJECT} and checking out ${PATCH}"
41 git clone https://git.opendaylight.org/gerrit/p/${PROJECT}
42 cd ${PROJECT_SHORTNAME}
43 git fetch https://git.opendaylight.org/gerrit/${PROJECT} refs/changes/${PATCH}
44 git checkout FETCH_HEAD
48 # if distribution was not cloned above, we still need to get it
49 if [ "${distribution_status}" == "not_patched" ]; then
50 git clone https://git.opendaylight.org/gerrit/p/integration/distribution
51 echo "<module>distribution</module>" >> $POM_FILE
55 echo "</modules>" >> $POM_FILE
56 echo "</project>" >> $POM_FILE
58 # by default we can stay in master branch or checkout something else here
59 if [ "${DISTRIBUTION_BRANCH_TO_BUILD}" != "master" ]; then
61 git checkout ${DISTRIBUTION_BRANCH_TO_BUILD}
65 # Extract the BUNDLEVERSION from the distribution pom.xml
66 BUNDLEVERSION=`xpath $BUILD_DIR/distribution/pom.xml '/project/version/text()' 2> /dev/null`
67 echo "Bundle version is ${BUNDLEVERSION}"
69 BUNDLEURL=${BUILD_URL}org.opendaylight.integration\$distribution-karaf/artifact/org.opendaylight.integration/distribution-karaf/${BUNDLEVERSION}/distribution-karaf-${BUNDLEVERSION}.zip
70 echo "Bundle url is ${BUNDLEURL}"
72 # Set BUNDLEVERSION & BUNDLEURL
73 echo BUNDLEVERSION=${BUNDLEVERSION} > ${WORKSPACE}/bundle.txt
74 echo BUNDLEURL=${BUNDLEURL} >> ${WORKSPACE}/bundle.txt