-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathRunPoliCheck.ps1
More file actions
34 lines (27 loc) · 1.07 KB
/
RunPoliCheck.ps1
File metadata and controls
34 lines (27 loc) · 1.07 KB
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
param(
[string]$BuildSourceDir,
[string]$folderName,
[string]$branchName,
[string]$resultRoot,
[string]$PoliCheckPath
)
#
#Example:
# RunPoliCheck.ps1 -BuildSourceDir "C:\BuildAgent\_work\32\s"
# -folderName "src"
# -branchName "odata.net-main"
# -resultRoot "C:\Users\ODatabld\Documents\PoliCheck\LatestRunResult"
# -PoliCheckPath "C:\Program Files (x86)\Microsoft\PoliCheck\"
#
$targetPath= "${BuildSourceDir}\${folderName}"
Write-Output "targetPath: ${targetPath}"
$result="${resultRoot}\${branchName}\poli_result_${folderName}.xml"
cd "${PoliCheckPath}"
.\Policheck.exe /F:$targetPath /T:9 /Sev:"1|2" /PE:2 /O:$result
$FileContent = Get-Content $result
$PassResult = Select-String -InputObject $FileContent -Pattern "<TermTbl />"
If ($PassResult.Matches.Count -eq 0) {
Write-Error "PoliCheck failed for target ${targetPath}. For details, please check this result file on build machine: ${result}: section <Result TotalOccurences=...>."
exit 1
}
Write-Output "PoliCheck pass for target ${targetPath}"