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