Path: blob/main/jobs/FreeBSD-main-scan_build/backtrace-submit.sh
1130 views
#!/bin/sh1#2# Usage: ./submit.sh <input directory> <output directory> <URL>34INPUT="$1"5BUILD="$2"6URL="$3"78TOKEN=${BACKTRACE_TOKEN}9if [ -z "${TOKEN}" ]; then10echo "BACKTRACE_TOKEN is not defined"11exit 112fi1314if test -z "${URL}"; then15URL="https://freebsd.sp.backtrace.io:6098/post?format=json&token=${TOKEN}"16fi1718if test -z "${BUILD}"; then19BUILD=tmp.backtrace20fi2122# The default number of reports to include in every chunk.23CHUNK_SIZE=2002425mkdir -p "${BUILD}/archives"2627SIZE_LIMIT="1000000c"2829REPORTS_COUNT=`find ${INPUT} -name '*.html' -size -${SIZE_LIMIT} | wc -l`30echo "Found ${REPORTS_COUNT} reports meeting size criteria..."3132# We limit individual report size for now, this will be removed in the future.33find ${INPUT} -name '*.html' -size -${SIZE_LIMIT} | split -l ${CHUNK_SIZE} - ${BUILD}/chunk.3435CHUNK_COUNT=`find ${BUILD} -maxdepth 1 -type f -name "chunk.*" | wc -l`3637echo "Generating ${CHUNK_COUNT} chunks..."3839counter=140for i in `find ${BUILD}/ -maxdepth 1 -type f -name "chunk.*"`; do41CHUNK=`basename $i`4243echo " + $counter [${CHUNK}]"44counter=`expr $counter + 1`4546tar cTfz "$i" "${BUILD}/archives/${CHUNK}.tar.gz"47done4849rm -f ${BUILD}/chunk.*5051echo "Submitting ${CHUNK_COUNT} chunks..."5253counter=15455QUERY_STRING="author=${CHANGE_AUTHOR}&build_id=${BUILD_ID}&build_number=${BUILD_NUMBER}&job_name=${JOB_NAME}&build_url=${BUILD_URL}&git_commit=${GIT_COMMIT}"5657for i in `find ${BUILD}/archives -type f -name '*.tar.gz'`; do58CHUNK=`basename $i`5960echo " + ${counter} [${CHUNK}]"61counter=`expr ${counter} + 1`6263env ALL_PROXY=http://proxy.nyi.freebsd.org:3128 \64curl -v -X POST https://sca.backtrace.io/api/sca/submit/clang-analyzer?${QUERY_STRING} \65-H 'Content-Type: multipart/form-data' \66-F report="@${i}" \67-F "submitUrl=${URL}"68done6970rm -rf ${BUILD}717273