#!/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
# 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"
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
# 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
git push origin $TAG
fi
-
-# upload to reprepro
-# TODO: implement
-
# show the changelog
dpkg-parsechangelog
#!/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
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..."