forked from ciricihq/gitlab-sonar-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar-scanner-run.sh
executable file
·67 lines (50 loc) · 1.52 KB
/
sonar-scanner-run.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
if [ -z "$SONAR_URL" ]; then
echo "Undefined \"SONAR_URL\" env" && exit 1
fi
URL=$SONAR_URL
COMMAND="sonar-scanner -Dsonar.host.url=$URL"
if [ ! -z "$SONAR_PROJECT_KEY" ]; then
COMMAND="$COMMAND -Dsonar.projectKey=$SONAR_PROJECT_KEY"
fi
if [ ! -z "$SONAR_TOKEN" ]; then
COMMAND="$COMMAND -Dsonar.login=$SONAR_TOKEN"
fi
if [ ! -z "$SONAR_PROJECT_VERSION" ]; then
COMMAND="$COMMAND -Dsonar.projectVersion=$SONAR_PROJECT_VERSION"
fi
if [ ! -z "$SONAR_DEBUG" ]; then
COMMAND="$COMMAND -X"
fi
if [ ! -z "$SONAR_SOURCES" ]; then
COMMAND="$COMMAND -Dsonar.sources=$SONAR_SOURCES"
fi
if [ ! -z "$SONAR_PROFILE" ]; then
COMMAND="$COMMAND -Dsonar.profile=$SONAR_PROFILE"
fi
if [ ! -z "$SONAR_GITLAB_PROJECT_ID" ]; then
COMMAND="$COMMAND -Dsonar.gitlab.project_id=$SONAR_GITLAB_PROJECT_ID"
fi
if [ ! -z "$SONAR_LANGUAGE" ]; then
COMMAND="$COMMAND -Dsonar.language=$SONAR_LANGUAGE"
fi
if [ ! -z "$SONAR_ENCODING" ]; then
COMMAND="$COMMAND -Dsonar.sourceEncoding=$SONAR_ENCODING"
fi
if [ ! -z $CI_BUILD_REF ]; then
COMMAND="$COMMAND -Dsonar.gitlab.commit_sha=$CI_BUILD_REF"
fi
if [ ! -z $CI_BUILD_REF_NAME ]; then
COMMAND="$COMMAND -Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME"
fi
if [ ! -z $SONAR_BRANCH ]; then
COMMAND="$COMMAND -Dsonar.branch=$SONAR_BRANCH"
fi
# `analysis by default
if [ ! -z $SONAR_ANALYSIS_MODE ]; then
COMMAND="$COMMAND -Dsonar.analysis.mode=$SONAR_ANALYSIS_MODE"
if [ $SONAR_ANALYSIS_MODE="preview" ]; then
COMMAND="$COMMAND -Dsonar.issuesReport.console.enable=true"
fi
fi
$COMMAND