]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
adding comments
authorMathias Klette <mathias.klette@profitbricks.com>
Tue, 26 Jun 2012 10:53:42 +0000 (12:53 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Tue, 26 Jun 2012 10:53:42 +0000 (12:53 +0200)
live_build.sh

index 05375e7b354c08474283a74c4d4feafb9a6b4538..837b6c61720b97b1240660e1ad23e99fa7d92c60 100755 (executable)
@@ -3,17 +3,34 @@
 
 set -e
 
-if [ "$1" == "" ] ; then
+if [ -z "${BUILD_NUMBER}" ]
+then
+    echo "\$BUILD_NUMBER is empty, not using Jenkins? Please export manually!"
+    exit 1
+fi
+
+#
+# Define default profile if none is given
+#
+if [ "$1" == "" ]
+then
        LIVE_TYPE="staging"
 else
        LIVE_TYPE=$1
 fi
 
+#
+# Define default settings
+#
 RSYNC_BASE=/srv/mirror/live-build
 BUILD_DATE=$(date +%Y%m%d%H%M)
 BUILD_ID="${LIVE_TYPE}-${BUILD_DATE}-${BUILD_NUMBER}"          # BUILD_ID is used without lb_build.sh...
 BUILD_TARGET=$RSYNC_BASE/$BUILD_ID
 
+#
+# Overwrite settings depending on profile used
+# - i.e. not enough space in PBB to contain all images
+# 
 case $LIVE_TYPE in 
     default|staging)
         RSYNC_SRC="$RSYNC_BASE/"
@@ -25,8 +42,14 @@ case $LIVE_TYPE in
         ;;
 esac
 
+#
+# Export variables for upcoming sudo-calls
+#
 export LIVE_TYPE TARGET_RSYNC BUILD_DATE BUILD_ID BUILD_TARGET TARGET_BASE
 
+#
+# Build
+#
 figlet "building $LIVE_TYPE with build_id $BUILD_ID"
 
 cd pserver.flexible
@@ -36,6 +59,11 @@ sudo bash ./lb_build.sh -p $LIVE_TYPE
 ls -larth tftpboot/debian-live/amd64/
 ls -larth binary/live/
 
+figlet "build OK"
+
+# 
+# Deploy
+#
 mkdir -p $BUILD_TARGET
 
 echo "Finally copying results..."
@@ -43,14 +71,18 @@ echo "Finally copying results..."
 cp -v tftpboot/debian-live/amd64/initrd.img-3* tftpboot/debian-live/amd64/vmlinuz-3* $BUILD_TARGET/
 cp -v binary/live/filesystem.squashfs $BUILD_TARGET/
 
-figlet "success"
+figlet "deploy OK"
+
+#
+# Mirror
+#
 echo
 sort binary/live/filesystem.packages
 echo
 echo "Now rsyncing results to $RSYNC_BASE ..."
 rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete $RSYNC_SRC/ rsync://$RSYNC_DST
 
-figlet "rsync success"
+figlet "mirror OK"
 
 #
 # cleanup /srv/mirror, keep MAX number of images
@@ -67,3 +99,4 @@ for i in $(ls -artd1 ./${LIVE_TYPE}-*) ; do
        fi
 done
 
+figlet "cleanup OK"