Skip to content

Commit 2b278b6

Browse files
committed
Do not run analysis on PR (secure env variables like SONAR_TOKEN are not always available)
1 parent f04a7c2 commit 2b278b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ matrix:
99
- dotnet: 2.1 # latest available release
1010
mono: none
1111
env:
12-
- WITH_SONAR_ANALYSIS=true
12+
- WITH_SONAR_ANALYSIS=$([ "$TRAVIS_PULL_REQUEST" = "false" ] && echo true || echo false)
1313
- TEST_RESULTS_PATH=./Mastercard.Developer.OAuth1Signer.Tests/bin
1414
solution: Mastercard.Developer.OAuth1Signer.sln
1515
install:
1616
- dotnet restore
17-
- test $WITH_SONAR_ANALYSIS && dotnet tool install --global dotnet-sonarscanner || echo 'Skipping sonarscanner install'
17+
- test "$WITH_SONAR_ANALYSIS" = "true" && dotnet tool install --global dotnet-sonarscanner || echo 'Skipping sonarscanner install'
1818
before_script:
1919
- export PATH="$PATH:$HOME/.dotnet/tools"
2020
- |
21-
test $WITH_SONAR_ANALYSIS && dotnet sonarscanner begin \
21+
test "$WITH_SONAR_ANALYSIS" = "true" && dotnet sonarscanner begin \
2222
/k:"$SONAR_PROJECT_KEY" \
2323
/n:"$SONAR_PROJECT_NAME" \
2424
/d:sonar.organization="$SONAR_ORGANIZATION_KEY" \
@@ -30,4 +30,4 @@ script:
3030
- dotnet test -c Release -l:"trx;LogFileName=tests.trx" -r:"bin/" /p:CollectCoverage=true /p:CoverletOutputFormat="opencover" /p:CoverletOutput="bin/coverage.xml"
3131
- dotnet publish -c Release
3232
after_success:
33-
- test $WITH_SONAR_ANALYSIS && dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN" || echo 'Skipping sonarscanner end'
33+
- test "$WITH_SONAR_ANALYSIS" = "true" && dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN" || echo 'Skipping sonarscanner end'

0 commit comments

Comments
 (0)