[barometer] Add Jerma jobs
[releng.git] / jjb / ci_gate_security / anteater-report-to-gerrit.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 set -o pipefail
4 export PATH=$PATH:/usr/local/bin/
5 EXITSTATUS=0
6
7 # This Log should always exist
8 if [[ -e securityaudit.log ]] ; then
9
10     #check if log has errors
11     if grep ERROR securityaudit.log; then
12         EXITSTATUS=1
13     fi
14
15     grep 'ERROR' securityaudit.log | awk -F"ERROR - " '{ print $2 }' | tr -d "\'\"" > shortlog
16
17     # Only report to Gerrit when there are errors to report.
18     if [[ -s shortlog ]]; then
19         echo -e "\nposting security audit report to gerrit...\n"
20         ssh -p 29418 gerrit.opnfv.org \
21             "gerrit review -p $GERRIT_PROJECT \
22             -m \"$(cat shortlog)\" \
23             $GERRIT_PATCHSET_REVISION \
24             --notify NONE"
25     fi
26
27     exit $EXITSTATUS
28 fi