[barometer] Add Jerma jobs
[releng.git] / jjb / ci_gate_security / anteater-security-audit-weekly.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 ANTEATER_SCAN_PATCHSET="${ANTEATER_SCAN_PATCHSET:-true}"
12
13 cd $WORKSPACE
14 REPORTDIR='.reports'
15 mkdir -p $REPORTDIR
16 # Ensure any user can read the reports directory
17 chmod 777 $REPORTDIR
18
19 ANTEATER_FILES="--patchset /home/opnfv/anteater/$PROJECT/patchset"
20
21 if [[ "$ANTEATER_SCAN_PATCHSET" == "true" ]]; then
22     echo "Generating patchset file to list changed files"
23     git diff HEAD^1 --name-only | sed "s#^#/home/opnfv/anteater/$PROJECT/#" > $WORKSPACE/patchset
24     echo "Changed files are"
25     echo "--------------------------------------------------------"
26     cat $WORKSPACE/patchset
27     echo "--------------------------------------------------------"
28 else
29     echo "Checking full project $PROJECT"
30     ANTEATER_FILES="--path /home/opnfv/anteater/$PROJECT"
31 fi
32
33 vols="-v $WORKSPACE:/home/opnfv/anteater/$PROJECT -v $WORKSPACE/$REPORTDIR:/home/opnfv/anteater/$REPORTDIR"
34 envs="-e PROJECT=$PROJECT"
35
36 echo "Pulling releng-anteater docker image"
37 echo "--------------------------------------------------------"
38 docker pull opnfv/releng-anteater
39 echo "--------------------------------------------------------"
40
41 cmd="docker run -i $envs $vols --rm opnfv/releng-anteater \
42 /home/opnfv/venv/bin/anteater --project $PROJECT $ANTEATER_FILES"
43 echo "Running docker container"
44 echo "$cmd"
45 $cmd > $WORKSPACE/securityaudit.log 2>&1
46 exit_code=$?
47 echo "--------------------------------------------------------"
48 echo "Docker container exited with code: $exit_code"
49 echo "--------------------------------------------------------"
50 exit 0