summaryrefslogtreecommitdiffstats
path: root/jjb/ci_gate_security/anteater-security-audit.sh
blob: d5c0e407c8a8740d347b2d5de1ca447616b96595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
cd $WORKSPACE
echo "Generating patchset file to list changed files"
git diff HEAD^1 --name-only | sed "s#^#/home/opnfv/anteater/$PROJECT/#" > $WORKSPACE/patchset
echo "Changed files are"
echo "--------------------------------------------------------"
cat $WORKSPACE/patchset
echo "--------------------------------------------------------"

vols="-v $WORKSPACE:/home/opnfv/anteater/$PROJECT"
envs="-e PROJECT=$PROJECT"

echo "Pulling releng-anteater docker image"
echo "--------------------------------------------------------"
docker pull opnfv/releng-anteater
echo "--------------------------------------------------------"

cmd="sudo docker run --privileged=true -id $envs $vols opnfv/releng-anteater /bin/bash"
echo "Running docker command $cmd"
container_id=$($cmd)
echo "Container ID is $container_id"
cmd="anteater --project $PROJECT --patchset /home/opnfv/anteater/$PROJECT/patchset"
echo "Executing command inside container"
echo "$cmd"
echo "--------------------------------------------------------"
docker exec $container_id $cmd > $WORKSPACE/securityaudit.log 2>&1
exit_code=$?
echo "--------------------------------------------------------"
echo "Stopping docker container with ID $container_id"
docker stop $container_id
cat securityaudit.log
exit 0