-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep.sh
executable file
·52 lines (40 loc) · 1.3 KB
/
step.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -ex
set -o pipefail
run_test()
{
command=$1
sev_threshold=$2
create_report=$3
target_file_arg=$4
additional_arguments=$5
if [[ "$create_report" == "yes" ]]; then
snyk $command --severity-threshold=$sev_threshold $target_file_arg $additional_arguments --json | snyk-to-html -o $BITRISE_DEPLOY_DIR/snyk_report.html
else
snyk $command --severity-threshold=$sev_threshold $target_file_arg $additional_arguments
fi
}
command_to_use=$command
if [[ -z "$command" ]]; then command_to_use="test"; fi
if [[ ${command_to_use} = "test_this_step" ]]; then
./run_tests.sh
exit $?
fi
packages="snyk"
if [[ "${create_report}" == "yes" ]]; then
packages="snyk snyk-to-html"
fi
npm install -g ${packages}
target_file_arg=""
org_arg=""
snyk auth ${auth_token}
[[ ! -z "$target_file" ]] && target_file_arg="--file=${target_file}"
[[ ! -z "$organization" ]] && org_arg="--org=${organization}"
if [[ "${fail_on_issues}" == "yes" ]]; then
run_test "${command_to_use}" ${severity_threshold} ${create_report} ${target_file_arg} ${additional_arguments}
else
run_test "${command_to_use}" ${severity_threshold} ${create_report} ${target_file_arg} ${additional_arguments} || true
fi
if [[ "${monitor}" == "yes" ]]; then
snyk monitor ${target_file_arg} ${org_arg} ${additional_arguments}
fi