From ec6dd62e598028a40b0bef4329a4abe56094cfc7 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Thu, 25 Jul 2013 13:23:27 +0200 Subject: [PATCH] implement uploading, add comments --- maven_post_build_debian_wrapper.sh | 28 +++++++++++++++++++++++----- maven_pre_build_debian_wrapper.sh | 18 ++++++++++++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/maven_post_build_debian_wrapper.sh b/maven_post_build_debian_wrapper.sh index 869a5f0..823b767 100755 --- a/maven_post_build_debian_wrapper.sh +++ b/maven_post_build_debian_wrapper.sh @@ -1,9 +1,20 @@ #!/bin/bash -DISTRIBUTION=$1 +# (c) 2013 Holger Levsen holger@layer-acht.org +# GPL2+ licenced + +# +# maven_post_build_debian_wrapper.sh +# +# this script is run after maven for maven build jobs +# it updates debian/changelog, builds the debian package(s) and uploads to our repo. +# + +DISTRIBUTION=$1 # we cannot derive the distro from the branch as there is wheezy+squeeze, so this has to come from the job definition VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[") VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \ "production-proposed-updates" "pre-staging" "staging") SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration") +REPO=pb-squeeze function containsElement () { local e @@ -48,6 +59,7 @@ function validateInput # set proper DISTRIBUTION for feature branches DISTRIBUTION=$(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-') fi + REPO="dev-squeeeze" APPEND_TO_VERSION="experimental" elif ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS" @@ -77,12 +89,14 @@ set -e # fail on error set -x # echo commands executed if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then + # generate debian/changelog entries since the last upload git-dch -a --ignore-branch --no-full --no-meta --id-length=7 -N $VERSION sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog else # change version in changelog git-dch -a --ignore-branch --no-full --no-meta --id-length=7 # replace first version (enclosed in brackets) with real version + # we cannot use (git-)dch as the version might be lower than the last sed -i "0,/(.*)/s//($VERSION)/" debian/changelog # replace first UNRELEASED with $DISTRIBUTION sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog @@ -91,6 +105,14 @@ fi # build debian package (just binary, no source package) dpkg-buildpackage -us -uc -b +# upload to reprepro +SOURCE=$(dpkg-parsechangelog 2>/dev/null|grep ^Source:|cut -d " " -f2) +cd $WORKSPACE/.. +# TODO: move configuration up +dcmd scp ${SOURCE}_${VERSION}_amd64.changes alexandria.pb.local:/srv/$REPO/incoming/profitbricks/ +cd $WORKSPACE +# TODO: cleanup uploaded files + # push back to git repo if build from master or hotfix/ if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then git add debian/changelog @@ -102,10 +124,6 @@ if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] git push origin $TAG fi - -# upload to reprepro -# TODO: implement - # show the changelog dpkg-parsechangelog diff --git a/maven_pre_build_debian_wrapper.sh b/maven_pre_build_debian_wrapper.sh index 086c051..29edd6e 100755 --- a/maven_pre_build_debian_wrapper.sh +++ b/maven_pre_build_debian_wrapper.sh @@ -1,7 +1,14 @@ #!/bin/bash +# (c) 2013 Holger Levsen holger@layer-acht.org +# GPL2+ licenced -#TODO: remove this debug output -export +# +# maven_pre_build_debian_wrapper.sh +# +# this script is run before maven for maven build jobs. +# most of the work happens through the maven jenkins plugin and through the +# maven_post_build_debian_wrapper.sh which is run after maven. +# set -e @@ -13,12 +20,19 @@ git reset --hard if [ ${GIT_BRANCH_NAME:0:8} = "feature/" ] ; then if [[ "$BUILD_TRIGGERS" == *"merge"* ]]; then + # + # if triggered to 'merge' via git commit, + # merge feature branch into integration branch + # echo "Switching to integration branch..." git checkout integration echo "Trying to fast-forward merge $GIT_BRANCH_NAME..." git merge --no-ff origin/$GIT_BRANCH_NAME fi elif [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then + # + # check whether we will able to 'git tag' after the build by trying it now + # VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[") TAG=$(echo $VERSION | tr '~' '_' | tr ':' ',') git tag $TAG -m "Testing whether there is already a tag $TAG..." -- 2.39.5