aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/jenkins-scratchbuilder
blob: c2e32fe7aa72f6a9a6e4d2a5a7750879d87f7d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 monotonically increasing changelog by including the build number
gbp 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"
gbp buildpackage ${GBP_OPTS} --git-ignore-branch --git-pbuilder --git-cleaner=/bin/true --git-ignore-new --git-pristine-tar -b