|
1 | 1 | # Description: Checks the PowerShell syntax of the script using PSScriptAnalyzer. |
2 | 2 | param([String]$pathToBuiltTasks) |
3 | 3 |
|
| 4 | +$internalFeedUrl = "https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/powershell-modules/nuget/v2" |
| 5 | +$internalRepoName = "AzDO-PSModules" |
| 6 | + |
| 7 | +# Register internal Azure Artifacts feed as PS repository (avoids external network calls to PSGallery) |
| 8 | +if (-Not (Get-PSRepository -Name $internalRepoName -ErrorAction SilentlyContinue)) { |
| 9 | + Register-PSRepository -Name $internalRepoName -SourceLocation $internalFeedUrl -InstallationPolicy Trusted |
| 10 | +} |
| 11 | + |
4 | 12 | function Get-AnalyzerSettings() { |
5 | 13 | return @{ |
6 | 14 | Severity=@('Error', 'Warning', 'Information', 'ParseError', 'ParseWarning') |
@@ -37,7 +45,7 @@ function Invoke-AnalyzerToTask() { |
37 | 45 | $module = Get-Module -Name "PSScriptAnalyzer"; |
38 | 46 | if ($module -eq $null) { |
39 | 47 | Write-Host "Installing PSScriptAnalyzer module..." |
40 | | - Install-Module -Name "PSScriptAnalyzer" -Scope CurrentUser -Force |
| 48 | + Install-Module -Name "PSScriptAnalyzer" -Scope CurrentUser -Force -Repository $internalRepoName |
41 | 49 | } |
42 | 50 |
|
43 | 51 | Write-Host "Running PSScriptAnalyzer for $taskPath." |
@@ -106,7 +114,7 @@ function main() { |
106 | 114 | $module = Get-Module -Name "Newtonsoft.Json"; |
107 | 115 | if ($module -eq $null) { |
108 | 116 | Write-Host "Installing Newtonsoft.Json module..." |
109 | | - Install-Module -Scope CurrentUser -Name "Newtonsoft.Json" -Force |
| 117 | + Install-Module -Scope CurrentUser -Name "Newtonsoft.Json" -Force -Repository $internalRepoName |
110 | 118 | } |
111 | 119 |
|
112 | 120 | # Get the tasks which have a PowerShell handler. |
|
0 commit comments