Dave Barach | 3ad7704 | 2017-01-04 17:24:32 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | token=${COVERITY_TOKEN} |
| 6 | email=dbarach@cisco.com |
| 7 | project="fd.io VPP" |
| 8 | project_encoded="fd.io+VPP" |
| 9 | url=https://scan.coverity.com |
| 10 | |
| 11 | export COV_HOST=$(hostname -f) |
| 12 | export COV_USER=vpp |
| 13 | |
| 14 | # Location of various directories |
| 15 | |
| 16 | # run script from .../build-root |
| 17 | |
| 18 | build_dir=`pwd` |
| 19 | covdir="${build_dir}/cov-int" |
| 20 | COVTOOLS="${COVTOOLS-/scratch/cov-analysis-latest}" |
| 21 | |
| 22 | # Before we run the build, check that we can submit one |
| 23 | check=$(curl -s --form project="${project}" \ |
| 24 | --form token="${token}" "${url}/api/upload_permitted") |
| 25 | if [ "${check}" = "Access denied" ]; then |
| 26 | echo "Bad token or project name." |
| 27 | exit 1 |
| 28 | fi |
| 29 | if [ "${check}" != '{"upload_permitted":true}' ]; then |
| 30 | echo "Upload not permitted; stop now..." |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | version=$(git describe) |
| 35 | |
| 36 | # Run the build |
| 37 | cd .. |
| 38 | "${COVTOOLS}/bin/cov-build" --dir "${covdir}" make bootstrap build-coverity |
| 39 | cd ${build_dir} |
| 40 | |
| 41 | # Tar the build artifacts that scan wants |
| 42 | tar -czf fd.io-vpp.tgz "$(basename ${covdir})" |
| 43 | # rm -rf "${covdir}" |
| 44 | |
| 45 | # Submit the build |
| 46 | echo curl --form token="${token}" \ |
| 47 | --form email="${email}" \ |
| 48 | --form file=@fd.io-vpp.tgz \ |
| 49 | --form version="${version}" \ |
| 50 | --form description="master:${version}" \ |
| 51 | "${url}/builds?project=${project_encoded}" |
| 52 | |
| 53 | # All done! |