#!/bin/bash
DISTRIBUTION=$1
VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[")
-SCRIPTNAME=${0##*/}
VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \
"production-proposed-updates" "pre-staging" "staging" "experimental")
-SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/")
+SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration")
function containsElement () {
local e
function startswithElement () {
local e
local l
- for e in "${@:2}";
- do
+ for e in "${@:2}"; do
l=${#e} # length of the element
# test if element equals $1 with the length of element:
[[ "$e" = "${1:0:$l}" ]] && return 0
function validateInput
{
if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then
- DISTRIBUTION="experimental"
+ if [ "$GIT_BRANCH_NAME" = "integration" ] ; then
+ DISTRIBUTION="unstable"
+ else
+ DISTRIBUTION="experimental"
+ if
fi
if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then
fi
if [ "$DISTRIBUTION" = "experimental" ] ; then
- # TODO
- echo TODO set DISTRIBUTION correctly
+ # set proper DISTRIBUTION for feature branches
+ DISTRIBUTION= $(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-')
fi
- if [[ -z "${VERSION}" ]]
- then
+ if [[ -z "${VERSION}" ]] ; then
echo "Need to specify version"
exit 1
fi
+
# TODO: we need to do better
VERSION=$(echo $VERSION | sed -s "s#SNAP#0SNAP#g")
echo "=================================="
# build debian package (just binary, no source package)
dpkg-buildpackage -us -uc -b
-# push back to git repo
-if [ "$GIT_BRANCH_NAME" = "master" ] ; then
- # TODO: git commit
+# 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 commit -m "Automatic commit by jenkins after build of $BUILD_NUMBER"
# TODO: git tag
- # TODO: git push
+ git push origin $GIT_BRANCH_NAME
fi
# upload to reprepro