James E. King III | a3a5909 | 2018-06-27 21:05:57 +0000 | [diff] [blame] | 1 | # |
| 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 | |
| 21 | set -ex |
| 22 | |
| 23 | COVERITY_SCAN_BUILD_COMMAND=${COVERITY_SCAN_BUILD_COMMAND:-build/docker/scripts/autotools.sh} |
| 24 | COVERITY_SCAN_DESCRIPTION=${COVERITY_SCAN_DESCRIPTION:-${TRAVIS_BRANCH:-master}} |
| 25 | COVERITY_SCAN_PROJECT=${COVERITY_SCAN_PROJECT:-thrift} |
| 26 | |
| 27 | # download the coverity scan package |
| 28 | |
| 29 | pushd /tmp |
| 30 | if [[ "$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 |
| 34 | fi |
| 35 | COVBIN=$(echo $(pwd)/cov-analysis*/bin) |
| 36 | export PATH=$COVBIN:$PATH |
| 37 | popd |
| 38 | |
| 39 | # build the project with coverity scan |
| 40 | |
| 41 | rm -rf cov-int/ |
| 42 | cov-build --dir cov-int $COVERITY_SCAN_BUILD_COMMAND |
| 43 | tar cJf cov-int.tar.xz cov-int/ |
| 44 | curl --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 | |