2019-06-04 12:12:11 +00:00
|
|
|
Param(
|
|
|
|
[string] $GuardianCliLocation,
|
|
|
|
[string] $WorkingDirectory,
|
|
|
|
[string] $GdnFolder,
|
|
|
|
[string] $UpdateBaseline,
|
2021-07-15 14:32:48 +00:00
|
|
|
[string] $GuardianLoggerLevel='Standard'
|
2019-06-04 12:12:11 +00:00
|
|
|
)
|
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
$ErrorActionPreference = 'Stop'
|
2019-06-04 12:12:11 +00:00
|
|
|
Set-StrictMode -Version 2.0
|
2019-11-22 13:41:58 +00:00
|
|
|
$disableConfigureToolsetImport = $true
|
2021-06-12 12:58:31 +00:00
|
|
|
$global:LASTEXITCODE = 0
|
2019-06-04 12:12:11 +00:00
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
try {
|
2020-03-31 13:04:58 +00:00
|
|
|
# `tools.ps1` checks $ci to perform some actions. Since the SDL
|
|
|
|
# scripts don't necessarily execute in the same agent that run the
|
|
|
|
# build.ps1/sh script this variable isn't automatically set.
|
|
|
|
$ci = $true
|
2019-11-22 13:41:58 +00:00
|
|
|
. $PSScriptRoot\..\tools.ps1
|
2019-06-04 12:12:11 +00:00
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
# We store config files in the r directory of .gdn
|
|
|
|
$gdnConfigPath = Join-Path $GdnFolder 'r'
|
|
|
|
$ValidPath = Test-Path $GuardianCliLocation
|
2019-06-04 12:12:11 +00:00
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
if ($ValidPath -eq $False)
|
|
|
|
{
|
|
|
|
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location."
|
|
|
|
ExitWithExitCode 1
|
2019-06-04 12:12:11 +00:00
|
|
|
}
|
2019-11-22 13:41:58 +00:00
|
|
|
|
2021-07-15 14:32:48 +00:00
|
|
|
$gdnConfigFiles = Get-ChildItem $gdnConfigPath -Recurse -Include '*.gdnconfig'
|
|
|
|
Write-Host "Discovered Guardian config files:"
|
|
|
|
$gdnConfigFiles | Out-String | Write-Host
|
|
|
|
|
|
|
|
Exec-BlockVerbosely {
|
|
|
|
& $GuardianCliLocation run `
|
|
|
|
--working-directory $WorkingDirectory `
|
|
|
|
--baseline mainbaseline `
|
|
|
|
--update-baseline $UpdateBaseline `
|
|
|
|
--logger-level $GuardianLoggerLevel `
|
|
|
|
--config @gdnConfigFiles
|
|
|
|
Exit-IfNZEC "Sdl"
|
2019-11-22 13:41:58 +00:00
|
|
|
}
|
2019-08-30 12:32:56 +00:00
|
|
|
}
|
2019-11-22 13:41:58 +00:00
|
|
|
catch {
|
|
|
|
Write-Host $_.ScriptStackTrace
|
2020-03-31 13:04:58 +00:00
|
|
|
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
|
2019-11-22 13:41:58 +00:00
|
|
|
ExitWithExitCode 1
|
2020-03-31 13:04:58 +00:00
|
|
|
}
|