VPP: Make script inclusion more readable
[ci-management.git] / jjb / scripts / vpp / coverity.sh
1 #!/bin/bash
2 FILE="scan.txt"
3 OUTPUT="output.txt"
4
5 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
6 dpkg -i google-chrome-stable_current_amd64.deb || true
7 apt-get install -f -y
8
9 google-chrome --headless --disable-gpu -dump-dom --no-sandbox https://scan.coverity.com/projects/fd-io-vpp > $FILE
10
11 grep -i '<dt>Newly detected</dt>' $FILE || exit 42
12
13 NEW=$(grep -i -B 1 '<dt>Newly detected</dt>' $FILE | grep -Eo '[0-9]{1,4}')
14 ELIM=$(grep -i -B 1 '<dt>Eliminated</dt>' $FILE | grep -Eo '[0-9]{1,4}')
15 OUT=$(grep -i -B 1 '<dt>Outstanding</dt>' $FILE | grep -Eo '[0-9]{1,4}')
16
17 #ls -lg $FILE
18 #cat $FILE
19
20 if [ "${OUT}" == "0" ]; then
21         echo 'Current outstanding issues are zero' > $OUTPUT
22         echo "Newly detected: $NEW" >> $OUTPUT
23                 echo "Eliminated: $ELIM" >> $OUTPUT
24                 echo "More details can be found at  https://scan.coverity.com/projects/fd-io-vpp/view_defects" >> $OUTPUT
25 else
26         echo "Current number of outstanding issues are $OUT Failing job"
27         echo "Current number of outstanding issues are $OUT" > $OUTPUT
28         echo "Newly detected: $NEW" >> $OUTPUT
29                 echo "Eliminated: $ELIM" >> $OUTPUT
30                 echo "More details can be found at  https://scan.coverity.com/projects/fd-io-vpp/view_defects" >> $OUTPUT
31         exit 1
32 fi