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.
7 if [ `dirname $0` != "." ]; then
8 echo "only run this script like ./`basename $0`"
15 if [ -z $WORKSPACE ]; then
16 export WORKSPACE=`pwd`
19 if [ -z $ANDROID_HOME ]; then
20 if [ -e ~/.android/bashrc ]; then
23 echo "ANDROID_HOME must be set!"
29 #------------------------------------------------------------------------------#
30 # cache pypi downloads
31 if [ -z $PIP_DOWNLOAD_CACHE ]; then
32 export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
36 #------------------------------------------------------------------------------#
37 # required Java 7 keytool/jarsigner for :file support
39 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
42 #------------------------------------------------------------------------------#
43 # run local tests, don't scan fdroidserver/ project for APKs
45 # this is a local repo on the Guardian Project Jenkins server
46 apksource=/var/www/fdroid
49 ./run-tests $apksource
52 #------------------------------------------------------------------------------#
53 # test building the source tarball
55 python2 setup.py sdist
58 #------------------------------------------------------------------------------#
59 # test install using site packages
62 virtualenv --python=python2 --system-site-packages $WORKSPACE/env
63 . $WORKSPACE/env/bin/activate
64 pip install -e $WORKSPACE
65 python2 setup.py install
67 # run tests in new pip+virtualenv install
68 . $WORKSPACE/env/bin/activate
69 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
72 #------------------------------------------------------------------------------#
73 # run git pre-commit hook for pep8, pyflakes, etc
77 #------------------------------------------------------------------------------#
82 # use the virtualenv python so pylint checks against its installed libs
83 PYTHONPATH=$WORKSPACE/.pylint-plugins python2 /usr/bin/pylint \
84 --output-format=parseable --reports=n \
85 --load-plugins astng_hashlib \
86 fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
88 # to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
89 # running pylint in the virtualenv is causing this FATAL error, which is a bug:
90 # https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
91 [ $(($? & 1)) = "1" ] && echo "FATALs found"
92 [ $(($? & 2)) = "2" ] && exit 2
93 [ $(($? & 4)) = "4" ] && exit 4