chiark / gitweb /
handle gradle-plugin 3.0 output apk location
[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 ls -ld /var/lib/libvirt/images
36 ls -l /var/lib/libvirt/images || echo no access
37 ls -lR ~/.vagrant.d/ || echo no access
38 virsh --connect qemu:///system list --all || echo cannot virsh list
39 cat /etc/issue
40
41 /sbin/ifconfig || true
42 hostname || true
43
44 # point to the Vagrant/VirtualBox configs created by reproducible_setup_fdroid_build_environment.sh
45 # these variables are actually set in fdroidserver/jenkins-build-makebuildserver
46 export SETUP_WORKSPACE=$(dirname $WORKSPACE)/reproducible_setup_fdroid_build_environment/fdroidserver
47 export XDG_CONFIG_HOME=$SETUP_WORKSPACE
48 export VBOX_USER_HOME=$SETUP_WORKSPACE/VirtualBox
49 export VAGRANT_HOME=$SETUP_WORKSPACE/vagrant.d
50
51 # let's see what is actually there:
52 find $SETUP_WORKSPACE | grep -v fdroiddata/metadata/ | cut -b43-9999
53
54 # the way we handle jenkins slaves doesn't copy the workspace to the slaves
55 # so we need to "manually" clone the git repo hereā€¦
56 cd $WORKSPACE
57
58 # set up Android SDK to use the Debian packages in stretch
59 export ANDROID_HOME=/usr/lib/android-sdk
60
61 # ignore username/password prompt for non-existant repos
62 git config --global url."https://fakeusername:fakepassword@github.com".insteadOf https://github.com
63 git config --global url."https://fakeusername:fakepassword@gitlab.com".insteadOf https://gitlab.com
64 git config --global url."https://fakeusername:fakepassword@bitbucket.org".insteadOf https://bitbucket.org
65
66 # now build the whole archive
67 cd $WORKSPACE
68
69 # this can be handled in the jenkins job, or here:
70 if [ -e fdroiddata ]; then
71     cd fdroiddata
72     git remote update -p
73     git checkout master
74     git reset --hard origin/master
75     # no don't `git clean` here, it'll wipe the APKs in unsigned/
76 else
77     git clone https://gitlab.com/fdroid/fdroiddata.git fdroiddata
78     cd fdroiddata
79 fi
80
81 echo "build_server_always = True" > config.py
82 $WORKSPACE/fdroid build --verbose --latest --no-tarball --all
83
84 vagrant global-status
85 cd builder
86 vagrant status