$github_branch_refs_parts = "%teamcity.build.branch%" -split "/" | |
$is_pr = ($github_branch_refs_parts.Count -eq 2 -and $github_branch_refs_parts[1] -eq "merge") | |
if (-Not $is_pr) { | |
Write-Host "Running SonarQube in master branch mode" | |
SonarQube.Scanner.MSBuild.exe begin /k:"%sonar.project%" /d:"sonar.host.url=%sonar.host.url%" /d:sonar.cs.dotcover.reportsPaths="dotCover.html" /v:"%build.number%" | |
} else { | |
Write-Host "Running SonarQube in PR Mode" | |
$pull_request_number = $github_branch_refs_parts[0] | |
$repo = "%repo_owner%" + "/" + "%name%" | |
$command = 'SonarQube.Scanner.MSBuild.exe' + | |
' begin' + | |
' /k:' + '%sonar_project%' + | |
' /v:' + "%build_number%" + | |
' /d:sonar.host.url=' + "%sonar_hosturl%" + | |
' /d:sonar.github.pullRequest=' + $pull_request_number + | |
' /d:sonar.github.repository=' + $repo + | |
' /d:sonar.github.oauth=' + "%sonarqube_github_oauth_token%" + | |
' /d:sonar.analysis.mode=' + "preview" + | |
' /d:sonar.scanAllFiles=' + "true" + | |
' /d:sonar.github.endpoint=' + "%github_api_endpoint%" | |
Write-Host $command | |
Invoke-Expression $command | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment