chiark / gitweb /
jenkins: move tests to separate job
[fdroidserver.git] / jenkins-build
1 #!/bin/bash
2 #
3 # this is the script run by the Jenkins server to run the build tests.  Be
4 # sure to always run it in its dir, i.e. ./jenkins-build, otherwise it might
5 # remove things that you don't want it to.
6
7 if [ `dirname $0` != "." ]; then
8     echo "only run this script like ./`basename $0`"
9     exit
10 fi
11
12 # jenkins.debian.net slaves do not export WORKSPACE
13 if [ -z $WORKSPACE ]; then
14     export WORKSPACE=`pwd`
15 fi
16
17 set -e
18 set -x
19
20 # report info about virtualization
21 (dmesg | grep -i -e hypervisor -e qemu -e kvm) || true
22 (lspci | grep -i -e virtio -e virtualbox -e qemu -e kvm) || true
23 lsmod
24 if systemd-detect-virt -q ; then
25         echo "Virtualization is used:" `systemd-detect-virt`
26 else
27         echo "No virtualization is used."
28 fi
29 sudo /bin/chmod -R a+rX /var/lib/libvirt/images
30 ulimit -n 2048
31 echo 'maximum allowed number of open file descriptors: ' `ulimit -n`
32 ls -ld /var/lib/libvirt/images
33 ls -l /var/lib/libvirt/images || echo no access
34 ls -lR ~/.vagrant.d/ || echo no access
35 virsh --connect qemu:///system list --all || echo cannot virsh list
36 cat /etc/issue
37
38 /sbin/ifconfig || true
39 hostname || true
40
41 # point to the Vagrant/VirtualBox configs created by reproducible_setup_fdroid_build_environment.sh
42 # these variables are actually set in fdroidserver/jenkins-build-makebuildserver
43 export SETUP_WORKSPACE=$(dirname $WORKSPACE)/reproducible_setup_fdroid_build_environment
44 export XDG_CONFIG_HOME=$SETUP_WORKSPACE
45 export VBOX_USER_HOME=$SETUP_WORKSPACE/VirtualBox
46 export VAGRANT_HOME=$SETUP_WORKSPACE/vagrant.d
47
48 # make sure we have the right buildserver paths and its ready for use
49 vagrant global-status | grep reproducible_setup_fdroid_build_environment
50
51 # the way we handle jenkins slaves doesn't copy the workspace to the slaves
52 # so we need to "manually" clone the git repo hereā€¦
53 cd $WORKSPACE
54
55 # set up Android SDK to use the Debian packages in stretch
56 export ANDROID_HOME=/usr/lib/android-sdk
57
58 # ignore username/password prompt for non-existant repos
59 git config --global url."https://fakeusername:fakepassword@github.com".insteadOf https://github.com
60 git config --global url."https://fakeusername:fakepassword@gitlab.com".insteadOf https://gitlab.com
61 git config --global url."https://fakeusername:fakepassword@bitbucket.org".insteadOf https://bitbucket.org
62
63 # now build the whole archive
64 cd $WORKSPACE
65
66 # this can be handled in the jenkins job, or here:
67 if [ -e fdroiddata ]; then
68     cd fdroiddata
69     git remote update -p
70     git checkout master
71     git reset --hard origin/master
72     # keep all the cloned source repos
73     git clean -fdx --exclude build
74 else
75     git clone https://gitlab.com/fdroid/fdroiddata.git fdroiddata
76     cd fdroiddata
77 fi
78
79 echo "build_server_always = True" > config.py
80 $WORKSPACE/fdroid build --verbose --latest --no-tarball --all
81
82 vagrant global-status
83 cd builder
84 vagrant status