-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjenkins-debian-build
executable file
·87 lines (72 loc) · 2.44 KB
/
jenkins-debian-build
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh -e
# This script is designed to automatically build Debian packages for Jenkins
#
# It is used in the two following jobs:
# S_aegir-debian-official-3.x
# S_aegir-debian-official
# D_aegir-debian-auto
DOMAIN=`hostname -f`
KEY="jenkins@$DOMAIN"
usage() {
cat <<EOF
Usage: $0 [ -hvn -k <key> ]
Build an automatic package with the provided key.
-h: this help
-v: show every command ran
-n: simulate: build but do not upload the package
-k <key>: sign the package with this key (default: $KEY)
-u: upload the package (default: don't upload)
-t <ref>: build the package from a ref, usually a tag
EOF
}
upload=false
official=false
set -- `getopt hvnk:ut: $*`
for i; do
case "$i" in
-h) shift; usage;;
-v) shift; set -x;;
-n) shift; simulate='echo > ';;
-k) shift; KEY=$1; shift;;
-u) shift; upload=true;;
-t) shift; tag=$1; shift;;
--) shift; break;;
esac
done
# the upstream version: strip the 6.x and turn the appendix into
# +N.foo where N is the number of commits since last tag and foo is
# the hash
if ! [ -z "$tag" ]; then
jenkins_version="$tag"
# we checkout the tag, using git reset
# this is necessary so that git-buildpackage doesn't complain about not being on a branch
git reset --hard $tag
else
version=$(sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
commit=$(git log -n 1 --oneline | sed 's/ .*$$//')
jenkins_version="${version}+${BUILD_NUMBER}.${commit}"
fi
echo "Building aegir-${jenkins_version} with key $KEY - build tag: ${BUILD_TAG}"
$simulate rm -rf build-area/*
if ! [ -z "$tag" ] ; then
$simulate git-buildpackage -k${KEY}
else
$simulate dch -D unstable -v ${jenkins_version} "automatic jenkins build ${BUILD_TAG}"
$simulate git commit -m"dummy commit for jenkins ${BUILD_TAG} autobuild" debian/changelog
$simulate git-buildpackage -k${KEY}
fi
if $upload; then
echo "Uploading package to aegir repository"
$simulate dput -f aegir build-area/*.changes
echo "Waiting 10 seconds to let reprepro pickup the new files"
$simulate sleep 10
# Check if we can find the new provision package in the right place.
debfile=`ls build-area/ | grep provision | grep deb | head -1`
if [ -f /srv/reprepro/pool/main/a/aegir*-provision/$debfile ]; then
echo "debian file built: $debfile"
else
echo "can't find debian file $debfile"
exit 1
fi
fi
$simulate git reset --hard ${GIT_COMMIT} || true