blob: cb3f283eb260c8083fe6ca0aceca364d54f3a422 [file] [log] [blame]
James E. King IIIa3a59092018-06-27 21:05:57 +00001#
2# Coverity Scan Travis build script
3# To run this interactively, set the environment variables yourself,
4# and run this inside a docker container.
5#
6# Command-Line Arguments
7#
8# --skipdownload to skip re-downloading the Coverity Scan build package (large)
9#
10# Environment Variables (required)
11#
12# COVERITY_SCAN_NOTIFICATION_EMAIL - email address to notify
13# COVERITY_SCAN_TOKEN - the Coverity Scan token (should be secure)
14#
15# Environment Variables (defaulted)
16#
17# COVERITY_SCAN_BUILD_COMMAND - defaults to "build/docker/scripts/autotools.sh"
18# COVERITY_SCAN_DESCRIPTION - defaults to TRAVIS_BRANCH or "master" if empty
19# COVERITY_SCAN_PROJECT - defaults to "thrift"
20
21set -ex
22
23COVERITY_SCAN_BUILD_COMMAND=${COVERITY_SCAN_BUILD_COMMAND:-build/docker/scripts/autotools.sh}
24COVERITY_SCAN_DESCRIPTION=${COVERITY_SCAN_DESCRIPTION:-${TRAVIS_BRANCH:-master}}
25COVERITY_SCAN_PROJECT=${COVERITY_SCAN_PROJECT:-thrift}
26
27# download the coverity scan package
28
29pushd /tmp
30if [[ "$1" != "--skipdownload" ]]; then
31 rm -rf coverity_tool.tgz cov-analysis*
32 wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=$COVERITY_SCAN_PROJECT" -O coverity_tool.tgz
33 tar xzf coverity_tool.tgz
34fi
35COVBIN=$(echo $(pwd)/cov-analysis*/bin)
36export PATH=$COVBIN:$PATH
37popd
38
39# build the project with coverity scan
40
41rm -rf cov-int/
42cov-build --dir cov-int $COVERITY_SCAN_BUILD_COMMAND
43tar cJf cov-int.tar.xz cov-int/
44curl --form token="$COVERITY_SCAN_TOKEN" \
45 --form email="$COVERITY_SCAN_NOTIFICATION_EMAIL" \
46 --form file=@cov-int.tar.xz \
47 --form version="$(git describe --tags)" \
48 --form description="$COVERITY_SCAN_DESCRIPTION" \
49 https://scan.coverity.com/builds?project="$COVERITY_SCAN_PROJECT"
50