summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbner Silva <abner@collabora.co.uk>2013-10-18 11:18:28 -0300
committerEdward Hervey <edward@collabora.com>2013-11-15 16:54:44 +0100
commitc6e54c374a5f8ccba1e35df34f99e77fdaf91838 (patch)
tree37592a42a30f7b79d71cd02f397137090ee26806
parentbc4738e5bf23515ab8f5c4724706fef8216a1518 (diff)
Add improvements to the commit script
- Getting Jenkins build number as a parameter - Using random temporary files - Commiting changes with diff message - Tagging as build_YYYYMMDD-buildnumber
-rwxr-xr-x[-rw-r--r--]commit-repo-tag.sh95
1 files changed, 83 insertions, 12 deletions
diff --git a/commit-repo-tag.sh b/commit-repo-tag.sh
index 07018fe..4ac52c6 100644..100755
--- a/commit-repo-tag.sh
+++ b/commit-repo-tag.sh
@@ -1,22 +1,93 @@
#!/bin/bash
-# start : default branch
+# Script for GStreamer Jenkins CI
-# repo sync should have been done before
+# start : default branch
+# build branch : jenkins-build-branch
+# Create a new repo manifest file based on the default one, but containing
+# the current git revision of all used projects. The new manifest is meant
+# to be used for tracking the code used during each Jenkins build.
+# The new manifest is tagged with the build number and pushed to a git branch.
+
+# param: <jenkins build number> - Jenkins build number for the current job
+
+# Important: repo sync should have been done before
+
+# Build branch where new manifest will be stored
BUILD_BRANCH=jenkins-build-branch
-TMP_FILENAME=tmp_manifest.xml
-repo manifest -r -o $TMP_FILENAME
-cd .repo/manifests
+# The default manifest file name
+MANIFEST_FILENAME=default.xml
+
+# Temporary file used to store the new manifest
+TMP_M_FILENAME=`mktemp --suffix=.xml`
+
+if [ $# = 0 ];
+then
+ echo "Usage: $0 <jenkins build number>"
+ exit 42
+fi
+
+# Get the jenkins build number
+BUILD_NUMBER=$1
+
+if [ ! -d ".repo" ];
+then
+ echo "Cannot find a repo directory. Aborting..."
+ exit
+fi
+
+echo
+echo "======================================================"
+echo
+
+# Gets the current repo root dir
+ROOT_DIR=`pwd`
+
+echo "Generating new manifest file."
+
+# Create new manifest with all revisions
+repo manifest -r -o $TMP_M_FILENAME
+
+# Change to build branch and add the new manifest
+cd $ROOT_DIR/.repo/manifests
git checkout $BUILD_BRANCH
-cp ../../$TMP_FILENAME ./default.xml
+cp $TMP_M_FILENAME $MANIFEST_FILENAME
+
+# Remove temporary file
+rm -fr $TMP_M_FILENAME
+
+# Temporary file used to store the new changes for commiting
+TMP_C_FILENAME=`mktemp --suffix=.msg`
+
+# Store changes for commiting
+git diff $MANIFEST_FILENAME > $TMP_C_FILENAME
+
+# Commit new manifest file
+git commit -F $TMP_C_FILENAME -- $MANIFEST_FILENAME || true
+
+echo "Tagging manifest for storaging."
-# Note: This will return with errors if there are not changes
-# FIXME : Would be great to have it include the list of changes...
-git commit -m "<commit message>" -- default.xml || true
+# Tag the new manifest version
+CUR_DATE=`date +%Y%m%d`
+git tag -a "build_$CUR_DATE-$BUILD_NUMBER" \
+ -m "Tagging manifest build $BUILD_NUMBER on $CURDATE"
-git tag -a <TAG> -m "<tag message>"
-git push $BUILD_BRANCH
+echo "Pushing new manifest to the branch $BUILD_BRANCH"
+
+# Push new manifest to the build branch
+git push origin $BUILD_BRANCH
+
+# Remove temporary file
+rm -fr $TMP_C_FILENAME
+
+# Move back to the default branch
git checkout default
-cd ../../
+
+# Go back to the root directory
+cd $ROOT_DIR
+
+echo
+echo "Done."
+echo "======================================================"