Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d505dfe

Browse files
committed
Added Sonnar branches
1 parent 34db68c commit d505dfe

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

.travis/run_sonar_scanner.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
MAIN_DEV_BRANCH="develop"
4+
BRANCH_SONAR_PROPERTY="sonar.branch.name"
5+
BRANCH_SONAR_TARGET_PROPERTY="sonar.branch.target"
6+
7+
function add_sonar_property {
8+
9+
echo "$1=$2" >> sonar-project.properties
10+
}
11+
12+
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
13+
BRANCH=$TRAVIS_BRANCH;
14+
PR_BRANCH=""
15+
echo "BRANCH=$BRANCH"
16+
else
17+
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
18+
PR_BRANCH=$TRAVIS_BRANCH
19+
echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
20+
21+
fi
22+
23+
24+
# We are updating sonar_properties only when is not a develop
25+
# if its a pull request we will create a separate
26+
if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then
27+
echo "Updating sonar properties to include branch name"
28+
29+
add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}"
30+
31+
if [ ! -z "$PR_BRANCH" ]; then
32+
echo "Updating sonar properties to include pr target branch name"
33+
add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${PR_BRANCH}"
34+
else
35+
add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}"
36+
fi
37+
38+
else
39+
echo "No need to update sonar we building on release or develop"
40+
fi
41+
42+
#Execute Sonar scanner
43+
sonar-scanner

sonar-project.properties

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ sonar.plsql.file.suffixes=sql,tab,pkb,tpb
2020
sonar.language=plsql
2121

2222
# Encoding of the source code. Default is default system encoding
23-
#sonar.sourceEncoding=UTF-8
24-
sonar.branch.name=test
25-
sonar.branch.target=source_Test
23+
#sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)