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 # Set up git committer name and email, needed for commit creation when cherry-picking.
20 export EMAIL="sandbox@jenkins.opendaylight.org"
21 # TODO: Is there a more appropriate e-mail?
22 export GIT_COMMITTER_NAME="Multipatch Job"
24 # TODO: Is "patches" still the correct word?
25 IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}"
27 # For each patch, clone the project.
28 # Optionally checkout a specific patch set.
29 # Also optionally, cherry-pick series of patch sets.
30 # Each patch is found in the ${PATCHES_TO_BUILD} variable
31 # as a comma separated list of project[=checkout][:cherry-pick]* values
33 # Example: PATCHES_TO_BUILD='odlparent=45/30045/2,yangtools:53/26853/25,mdsal,controller=61/29761/5:45/29645/6,bgpcep:39/30239/1:59/30059/2'
35 distribution_status="not_included"
36 for patch_code in "${PATCHES[@]}"
38 echo "working on ${patch_code}"
39 PROJECT=`echo ${patch_code} | cut -d\: -f 1 | cut -d\= -f 1`
40 if [ "${PROJECT}" == "integration/distribution" ]; then
41 distribution_status="included"
43 PROJECT_SHORTNAME="${PROJECT##*/}" # http://stackoverflow.com/a/3162500
44 echo "cloning project ${PROJECT}"
45 git clone "https://git.opendaylight.org/gerrit/p/${PROJECT}"
46 echo "<module>${PROJECT_SHORTNAME}</module>" >> ${POM_FILE}
47 cd ${PROJECT_SHORTNAME}
48 CHECKOUT=`echo ${patch_code} | cut -d\= -s -f 2 | cut -d\: -f 1`
49 if [ "x${CHECKOUT}" != "x" ]; then
50 echo "checking out ${CHECKOUT}"
51 git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/$CHECKOUT"
52 git checkout FETCH_HEAD
54 echo "checking out ${DISTRIBUTION_BRANCH_TO_BUILD}"
55 git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
57 PICK_SEGMENT=`echo "${patch_code}" | cut -d\: -s -f 2-`
58 IFS=':' read -ra PICKS <<< "${PICK_SEGMENT}"
59 for pick in "${PICKS[@]}"
61 echo "cherry-picking ${pick}"
62 git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/${pick}"
63 git cherry-pick --ff --keep-redundant-commits FETCH_HEAD
68 if [ "${distribution_status}" == "not_included" ]; then
69 echo "adding integration/distribution"
70 # clone distribution and add it as a module in root pom
71 git clone "https://git.opendaylight.org/gerrit/p/integration/distribution"
73 git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
75 echo "<module>distribution</module>" >> ${POM_FILE}
79 echo "</modules>" >> ${POM_FILE}
80 echo "</project>" >> ${POM_FILE}
82 # Extract the BUNDLEVERSION from the distribution pom.xml
83 BUNDLEVERSION=`xpath $BUILD_DIR/distribution/pom.xml '/project/version/text()' 2> /dev/null`
84 echo "Bundle version is ${BUNDLEVERSION}"
86 BUNDLEURL=${BUILD_URL}org.opendaylight.integration\$distribution-karaf/artifact/org.opendaylight.integration/distribution-karaf/${BUNDLEVERSION}/distribution-karaf-${BUNDLEVERSION}.zip
87 echo "Bundle url is ${BUNDLEURL}"
89 # Set BUNDLEVERSION & BUNDLEURL
90 echo BUNDLEVERSION=${BUNDLEVERSION} > ${WORKSPACE}/bundle.txt
91 echo BUNDLEURL=${BUNDLEURL} >> ${WORKSPACE}/bundle.txt