Skip to content

Commit 05e81f7

Browse files
committed
Skip sonarqube analysis on pull request builds
Sonarqube requires the credentials for sonarqube.io when analysing the project. Since these are stored in encrypted env variables on Travis they are not available on pull request builds which causes the build to fail.
1 parent eeda569 commit 05e81f7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ before_install:
1616

1717
script:
1818
- ./gradlew check
19-
- ./gradlew sonarqube
19+
- ./travis/sonarqube.sh
2020

2121
after_success:
2222
- ./travis/publish.sh

travis/sonarqube.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
function main {
4+
require_no_pull_request
5+
./gradlew sonarqube
6+
}
7+
8+
function require_no_pull_request {
9+
if [ -v TRAVIS_PULL_REQUEST -a "$TRAVIS_PULL_REQUEST" != "false" ]; then
10+
echo "Building pull request. Skipping sonarqube analysis"
11+
exit 0
12+
fi
13+
}
14+
15+
main

0 commit comments

Comments
 (0)