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

Skip to content

Commit 2d09f43

Browse files
committed
Update sonar properties
1 parent bf00103 commit 2d09f43

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ cache:
6464
- $MAVEN_CFG
6565

6666
before_install:
67+
#debug
68+
- if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then bash .travis/run_sonar_scanner.sh; fi
6769
#The update_project_version.sh is done before deployment to validate that the change of project files does not break installation
6870
- bash .travis/update_project_version.sh
6971
# download latest utPLSQL release

.travis/run_sonar_scanner.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
#!/usr/bin/env bash
22

33
MAIN_DEV_BRANCH="develop"
4+
45
BRANCH_SONAR_PROPERTY="sonar.branch.name"
56
BRANCH_SONAR_TARGET_PROPERTY="sonar.branch.target"
67

7-
function add_sonar_property {
8+
PR_SONAR_BRANCH_PROPERTY="sonar.pullrequest.branch"
9+
PR_KEY_PROPERTY="sonar.pullrequest.key"
10+
PR_SONAR_BASE_PROPERTY="sonar.pullrequest.base"
11+
PR_SONAR_TOKEN_PROPERTY="sonar.pullrequest.github.token.secured"
812

13+
#Add property to file
14+
function add_sonar_property {
915
echo "$1=$2" >> sonar-project.properties
1016
}
1117

18+
1219
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
1320
BRANCH=$TRAVIS_BRANCH;
1421
PR_BRANCH=""
@@ -20,25 +27,28 @@ else
2027

2128
fi
2229

23-
add_sonar_property "sonar.pullrequest.github.token.secured" "${GITHUB_TRAVISCI_TOKEN}"
2430

25-
# We are updating sonar_properties only when is not a develop
26-
# if its a pull request we will create a separate
31+
#Are we running on develop branch ?
32+
echo "Check if we running from develop or on branch"
2733
if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then
28-
echo "Updating sonar properties to include branch name"
29-
30-
add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}"
3134

32-
if [ ! -z "$PR_BRANCH" ]; then
33-
echo "Updating sonar properties to include pr target branch name"
34-
add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${PR_BRANCH}"
35-
else
35+
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
36+
echo "Updating sonar properties to include branch name"
37+
add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}"
3638
add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}"
37-
fi
38-
39+
else
40+
echo "Updating sonar properties to include pull request name"
41+
add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}"
42+
add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}"
43+
add_sonar_property "${PR_KEY_PROPERTY}" "${PR}"
44+
add_sonar_property "${PR_SONAR_BASE_PROPERTY}" "${PR_BRANCH}"
45+
fi
3946
else
4047
echo "No need to update sonar we building on release or develop"
4148
fi
4249

50+
#debug
51+
cat sonar-project.properties
52+
4353
#Execute Sonar scanner
44-
sonar-scanner
54+
#sonar-scanner

sonar-project.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ sonar.projectDescription=PL/SQL Unit Testing Framework
1919
sonar.plsql.file.suffixes=sql,tab,pkb,tpb
2020
sonar.language=plsql
2121

22+
sonar.pullrequest.provider=github
2223
sonar.pullrequest.github.endpoint=https://api.github.com/
2324
sonar.pullrequest.github.repository=utPLSQL/utPLSQL
2425

0 commit comments

Comments
 (0)