-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sonar-begin.ps1
49 lines (43 loc) · 1.62 KB
/
sonar-begin.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$buildDir = $env:AGENT_BUILDDIRECTORY
$sourceDir = $env:BUILD_SOURCESDIRECTORY
$version = 1.0
write-host "Agent.BuildDirectory: " $buildDir
write-host "Build.SourcesDirectoy: " $sourceDir
write-host "Version: " $version
if ("main" -ne $env:BUILD_SOURCEBRANCHNAME)
{
$pullrequest = $true
$source = $env:BUILD_SOURCEBRANCH
$base = $env:SYSTEM_PULLREQUEST_TARGETBRANCH
$branch = $env:SYSTEM_PULLREQUEST_SOURCEBRANCH
$key = $env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
Write-Host "PR Yes: " $pullrequest
Write-Host "soruce: " $source
Write-Host "sonar.pullrequest.base: " $base
Write-Host "sonar.pullrequest.branch: " $branch
Write-Host "sonar.pullrequest.key: " $key
dotnet sonarscanner begin `
/k:wangkanai_architecture `
/o:wangkanai `
/v:$version `
/s:$sourceDir/SonarQube.Analysis.xml `
/d:sonar.host.url=https://sonarcloud.io `
/d:sonar.cs.vscoveragexml.reportsPaths=$sourceDir/coverage.xml `
/d:sonar.pullrequest.base=$base `
/d:sonar.pullrequest.branch=$branch `
/d:sonar.pullrequest.key=$key
}
else
{
$base = "main"
Write-Host "PR Not: " $pullrequest
Write-Host "sonar.branch.name : " $base
dotnet sonarscanner begin `
/k:wangkanai_architecture `
/o:wangkanai `
/v:$version `
/s:$sourceDir/SonarQube.Analysis.xml `
/d:sonar.host.url=https://sonarcloud.io `
/d:sonar.cs.vscoveragexml.reportsPaths=$sourceDir/coverage.xml `
/d:sonar.branch.name=$base
}