X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fintegration%2Fmultipatch-distribution.sh;h=6022254446d0a9f4dce5ceb51f5d873c18ccac6f;hb=321d2beb638ea788003884f7aefdde104464c0cc;hp=95d4fedea2b18744e5c68c12c9fda8dab472046c;hpb=47733870592d1deaa9aab54d0922ab4dd4d79d80;p=releng%2Fbuilder.git diff --git a/jjb/integration/multipatch-distribution.sh b/jjb/integration/multipatch-distribution.sh old mode 100644 new mode 100755 index 95d4fedea..602225444 --- a/jjb/integration/multipatch-distribution.sh +++ b/jjb/integration/multipatch-distribution.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # TODO: 1) clean up inline todo's below :) # TODO: 2) Use just a topic branch to create a distribution. see this email: # https://lists.opendaylight.org/pipermail/discuss/2015-December/006040.html @@ -22,21 +24,76 @@ cd $BUILD_DIR || exit 1 # Set up git committer name and email, needed for commit creation when cherry-picking. export EMAIL="sandbox@jenkins.opendaylight.org" -# TODO: Is there a more appropriate e-mail? export GIT_COMMITTER_NAME="Multipatch Job" -# TODO: Is "patches" still the correct word? +# Extract a list of patches per project from an comment trigger. An example is: +# Patch Set 1: +# +# multipatch-build:openflowplugin:45/69445/1,genius:46/69446/1,netvirt:47/69447/1 if [ -n "$GERRIT_EVENT_COMMENT_TEXT" ]; then - PATCHES_TO_BUILD=$(echo "$GERRIT_EVENT_COMMENT_TEXT" \ - | grep 'multipatch-build:' | awk -F: '{print $2}') + if [[ "$GERRIT_EVENT_COMMENT_TEXT" == *fast* ]]; then + BUILD_FAST="true" + PATCHES_TO_BUILD=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'multipatch-build-fast:') + else + BUILD_FAST="false" + PATCHES_TO_BUILD=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'multipatch-build:') + fi + PATCHES_TO_BUILD=${PATCHES_TO_BUILD#*:} fi +if ${BUILD_FAST}; then + fast_option="-Pq" +else + fast_option="" +fi +# check if topic exists, e.g. topic=binding-tlc-rpc +if [[ "${PATCHES_TO_BUILD}" == *topic* ]]; then + TOPIC="${PATCHES_TO_BUILD#*=}" + echo "Create topic ${TOPIC} patch list" + PATCHES_TO_BUILD="" + read -ra PROJECT_LIST <<< "${BUILD_ORDER}" + for PROJECT in "${PROJECT_LIST[@]}"; do + # get all patches number for a topic for a given project + IFS=$'\n' read -rd '' -a GERRIT_PATCH_LIST <<< "$(ssh -p 29418 jenkins-$SILO@git.opendaylight.org gerrit query status:open topic:${TOPIC} project:${PROJECT} \ + | grep 'number:' | awk '{{ print $2 }}')" || true + echo "Add ${PROJECT}:${GERRIT_PATCH_LIST[*]}" + # add project if it is the first with patches or it is not the first + if [[ -z "${PATCHES_TO_BUILD}" && ! -z "${GERRIT_PATCH_LIST[*]}" ]]; then + PATCHES_TO_BUILD="${PROJECT}" + elif [[ ! -z "${PATCHES_TO_BUILD}" ]]; then + PATCHES_TO_BUILD="${PATCHES_TO_BUILD},${PROJECT}" + fi + # sort project patches + if [[ ! -z "${GERRIT_PATCH_LIST[*]}" ]]; then + REF_LIST=() + # create reference list with patch number-refspec + for PATCH in "${GERRIT_PATCH_LIST[@]}"; do + REFSPEC=$(ssh -p 29418 jenkins-$SILO@git.opendaylight.org gerrit query change:${PATCH} --current-patch-set \ + | grep 'ref:' | awk '{{ print $2 }}') + REF_LIST+=("${PATCH}-${REFSPEC/refs\/changes\/}") + done + # sort reference list by patch number + IFS=$'\n' SORT_REF=$(sort <<<"${REF_LIST[*]}") && unset IFS + read -rd '' -a SORT_REF_LIST <<< "${SORT_REF[*]}" || true + # add refspec to patches to build list + for PATCH in "${SORT_REF_LIST[@]}"; do + PATCHES_TO_BUILD="${PATCHES_TO_BUILD}:${PATCH/*-/}" + done + fi + done +fi + +echo "Patches to build: ${PATCHES_TO_BUILD}" IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}" +# First phase: clone the necessary repos and set the patches up + +declare -a PROJECTS + # For each patch: # * Clone the project. # * Optionally, checkout a specific (typically unmerged) Gerrit patch. If none, # default to Integration/Distribution branch via {branch} JJB param. -# * Also optionally, cherry-pick series of patchs on top of the checkout. +# * Also optionally, cherry-pick series of patches on top of the checkout. # * Final option: perform a 'release' by removing "-SNAPSHOT" everywhere within the project. # # Each patch is found in the ${PATCHES_TO_BUILD} variable as a comma separated @@ -46,11 +103,11 @@ IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}" # # PATCHES_TO_BUILD='odlparent=45/30045/2' # -# Checkout patchs for both odlparent and yangtools. +# Checkout patches for both odlparent and yangtools: # # PATCHES_TO_BUILD='odlparent=45/30045/2,yangtools:53/26853/25' # -# Checkout a patch for controller, cherry-pick another patch on top of it. +# Checkout a patch for controller, cherry-pick another patch on top of it: # # PATCHES_TO_BUILD='controller=61/29761/5:45/29645/6' distribution_status="not_included" @@ -63,6 +120,7 @@ do distribution_status="included" fi PROJECT_SHORTNAME="${PROJECT##*/}" # http://stackoverflow.com/a/3162500 + PROJECTS+=("${PROJECT_SHORTNAME}") echo "cloning project ${PROJECT}" git clone "https://git.opendaylight.org/gerrit/p/${PROJECT}" cd ${PROJECT_SHORTNAME} || exit 1 @@ -95,31 +153,42 @@ do # Here 'r' means release. Useful for testing Nitrogen Odlparent changes. find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//g' fi - # Build project - "$MVN" clean install \ - -e -Pq \ - -Dstream=oxygen \ - -Dgitid.skip=false \ - -Dmaven.gitcommitid.skip=false \ - --global-settings "$GLOBAL_SETTINGS_FILE" \ - --settings "$SETTINGS_FILE" \ - $MAVEN_OPTIONS cd "${BUILD_DIR}" || exit 1 done if [ "${distribution_status}" == "not_included" ]; then echo "adding integration/distribution" + PROJECTS+=(distribution) # clone distribution and add it as a module in root pom git clone "https://git.opendaylight.org/gerrit/p/integration/distribution" cd distribution || exit 1 git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}" + cd "${BUILD_DIR}" || exit 1 +fi + +# Second phase: build everything + +for PROJECT_SHORTNAME in "${PROJECTS[@]}"; do + pushd "${PROJECT_SHORTNAME}" || exit 1 # Build project "$MVN" clean install \ - -e -Pq \ + -e ${fast_option} \ -Dstream="$DISTROSTREAM" \ + -Dgitid.skip=false \ + -Dmaven.gitcommitid.skip=false \ --global-settings "$GLOBAL_SETTINGS_FILE" \ --settings "$SETTINGS_FILE" \ $MAVEN_OPTIONS - cd "${BUILD_DIR}" || exit 1 -fi + # Since we've installed the artifacts, we can clean the build and save + # disk space + "$MVN" clean \ + -e ${fast_option} \ + -Dstream="$DISTROSTREAM" \ + -Dgitid.skip=false \ + -Dmaven.gitcommitid.skip=false \ + --global-settings "$GLOBAL_SETTINGS_FILE" \ + --settings "$SETTINGS_FILE" \ + $MAVEN_OPTIONS + popd || exit 1 +done