1 # TODO: 1) clean up inline todo's below :)
2 # TODO: 2) Use just a topic branch to create a distribution. see this email:
3 # https://lists.opendaylight.org/pipermail/discuss/2015-December/006040.html
4 # TODO: 3) Bubble up CSIT jobs that are triggered by the multipatch job to a jenkins
5 # parameter. the default can be distribution-test which calls all CSIT jobs
6 # but being able to easily override it to a smaller subset (or none) will be
9 # create a fresh empty place to build this custom distribution
10 BUILD_DIR=${WORKSPACE}/patch_tester
11 POM_FILE=${WORKSPACE}/patch_tester/pom.xml
12 DISTRIBUTION_BRANCH_TO_BUILD=$BRANCH #renaming variable for clarity
18 # create a root pom that will contain a module for each project we have a patch for
19 echo "<project>" >> $POM_FILE
20 echo "<groupId>org.opendaylight.test</groupId>" >> $POM_FILE
21 echo "<artifactId>test</artifactId>" >> $POM_FILE
22 echo "<version>0.1</version>" >> $POM_FILE
23 echo "<modelVersion>4.0.0</modelVersion>" >> $POM_FILE
24 echo "<packaging>pom</packaging>" >> $POM_FILE
25 echo "<modules>" >> $POM_FILE
27 # Set up git committer name and email, needed for commit creation when cherry-picking.
28 export EMAIL="sandbox@jenkins.opendaylight.org"
29 # TODO: Is there a more appropriate e-mail?
30 export GIT_COMMITTER_NAME="Multipatch Job"
32 # TODO: Is "patches" still the correct word?
33 IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}"
35 # For each patch, clone the project.
36 # Optionally checkout a specific patch set.
37 # Also optionally, cherry-pick series of patch sets.
38 # Each patch is found in the ${PATCHES_TO_BUILD} variable
39 # as a comma separated list of project[=checkout][:cherry-pick]* values
41 # 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'
43 distribution_status="not_included"
44 for patch_code in "${PATCHES[@]}"
46 echo "working on ${patch_code}"
47 PROJECT=`echo ${patch_code} | cut -d\: -f 1 | cut -d\= -f 1`
48 if [ "${PROJECT}" == "integration/distribution" ]; then
49 distribution_status="included"
51 PROJECT_SHORTNAME="${PROJECT##*/}" # http://stackoverflow.com/a/3162500
52 echo "cloning project ${PROJECT}"
53 git clone "https://git.opendaylight.org/gerrit/p/${PROJECT}"
54 echo "<module>${PROJECT_SHORTNAME}</module>" >> ${POM_FILE}
55 cd ${PROJECT_SHORTNAME}
56 CHECKOUT=`echo ${patch_code} | cut -d\= -s -f 2 | cut -d\: -f 1`
57 if [ "x${CHECKOUT}" != "x" ]; then
58 echo "checking out ${CHECKOUT}"
59 git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/$CHECKOUT"
60 git checkout FETCH_HEAD
62 echo "checking out ${DISTRIBUTION_BRANCH_TO_BUILD}"
63 git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
65 PICK_SEGMENT=`echo "${patch_code}" | cut -d\: -s -f 2-`
66 IFS=':' read -ra PICKS <<< "${PICK_SEGMENT}"
67 for pick in "${PICKS[@]}"
69 echo "cherry-picking ${pick}"
70 git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/${pick}"
71 git cherry-pick --ff --keep-redundant-commits FETCH_HEAD
76 if [ "${distribution_status}" == "not_included" ]; then
77 echo "adding integration/distribution"
78 # clone distribution and add it as a module in root pom
79 git clone "https://git.opendaylight.org/gerrit/p/integration/distribution"
81 git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
83 echo "<module>distribution</module>" >> ${POM_FILE}
87 echo "</modules>" >> ${POM_FILE}
88 echo "</project>" >> ${POM_FILE}
90 # Extract the BUNDLEVERSION from the distribution pom.xml
91 BUNDLEVERSION=`xpath $BUILD_DIR/distribution/pom.xml '/project/version/text()' 2> /dev/null`
92 echo "Bundle version is ${BUNDLEVERSION}"
94 BUNDLEURL=${BUILD_URL}org.opendaylight.integration\$distribution-karaf/artifact/org.opendaylight.integration/distribution-karaf/${BUNDLEVERSION}/distribution-karaf-${BUNDLEVERSION}.zip
95 echo "Bundle url is ${BUNDLEURL}"
97 # Set BUNDLEVERSION & BUNDLEURL
98 echo BUNDLEVERSION=${BUNDLEVERSION} > ${WORKSPACE}/bundle.txt
99 echo BUNDLEURL=${BUNDLEURL} >> ${WORKSPACE}/bundle.txt