aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-05-05 12:59:56 +0200
committerGuido Günther <agx@sigxcpu.org>2013-05-30 15:22:36 +0200
commit9c5bd03ef736ff65cf68ca1a278c0647e72862c1 (patch)
tree859b3d3249982628cb398932c39654a4559029c7
parent47f2deaa698cbbe6da7cc03399c3e78cc251a01b (diff)
Add Jenkins Scratchbuilder example
It's a simple script that can be used to build Debian packages via gbp and Jenkins.
-rw-r--r--examples/jenkins-scratchbuilder41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/jenkins-scratchbuilder b/examples/jenkins-scratchbuilder
new file mode 100644
index 00000000..0f439a5c
--- /dev/null
+++ b/examples/jenkins-scratchbuilder
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# - Use "execute shell" step in Jenkins like
+#
+# export ARCH=i386
+# export DIST=sid
+# jenkins-scratchbuilder
+#
+# - jenkins must be be able to invoke cowbuilder/pbuilder via sudo:
+#
+# %pbuilder ALL = SETENV: NOPASSWD: /usr/sbin/cowbuilder, /usr/sbin/pbuilder
+#
+# - It assumes you checked out the sources into scratchbuild/
+
+set +e
+
+# Remove old build artifacts from workspace
+rm -f *.deb *.changes *.build *.dsc
+
+# We assume jenkins was told to checkout into a specific subdir
+# named scratchbuild
+cd scratchbuild/
+
+# Make sure we have an uptodate cowbuilder environment
+# Note that git-pbuilder will pick up $DIST and $ARCH from the environment
+[ -d /var/cache/pbuilder/base.cow ] || git-pbuilder create
+git-pbuilder update
+
+# Cleanup any leftovers
+git clean -dfx
+
+# Reset the changelog
+git checkout -f debian/changelog
+
+# Create a monitonically increasing changelog by including the build number
+git-dch -S -a --ignore-branch --snapshot-number=${BUILD_NUMBER}
+
+# Build the package
+[ -z ARCH ] || GBP_OPTS="$GBP_OPTS --git-arch=$ARCH"
+[ -z DIST ] || GBP_OPTS="$GBP_OPTS --git-dist=$DIST"
+git-buildpackage ${GBP_OPTS} --git-ignore-branch --git-pbuilder --git-cleaner=/bin/true --git-ignore-new --git-pristine-tar -b