diff --git a/Tasks/AzurePowerShellV2/AzurePowerShell.ps1 b/Tasks/AzurePowerShellV2/AzurePowerShell.ps1 index c3ab4857233a..0381260cc131 100644 --- a/Tasks/AzurePowerShellV2/AzurePowerShell.ps1 +++ b/Tasks/AzurePowerShellV2/AzurePowerShell.ps1 @@ -144,8 +144,4 @@ finally { Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ Disconnect-AzureAndClearContext -authScheme $authScheme -ErrorAction SilentlyContinue - - # Telemetry - $telemetryJsonContent = @{ targetAzurePs = $targetAzurePs } | ConvertTo-Json -Compress - Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV2]$telemetryJsonContent" } diff --git a/Tasks/AzurePowerShellV2/TryMakingModuleAvailable.ps1 b/Tasks/AzurePowerShellV2/TryMakingModuleAvailable.ps1 index 10a92c351259..b0b4662bf0f9 100644 --- a/Tasks/AzurePowerShellV2/TryMakingModuleAvailable.ps1 +++ b/Tasks/AzurePowerShellV2/TryMakingModuleAvailable.ps1 @@ -4,36 +4,68 @@ param ( $targetVersion ) -. "$PSScriptRoot\Utility.ps1" -$moduleContainerPath = Get-SavedModuleContainerPath +try { + . "$PSScriptRoot\Utility.ps1" + $moduleContainerPath = Get-SavedModuleContainerPath -if (-not(Test-Path -Path $moduleContainerPath)) { - Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic." - return; -} - -if (!$targetVersion) { - Write-Verbose "Latest module selected which will be available as folder." - return; -} - -# value for classic -@($false, $true).ForEach({ - $modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_; - if (Test-Path -Path $modulePath) { - Write-Verbose "Module available as folder at $modulePath" + if (-not(Test-Path -Path $moduleContainerPath)) { + $classicModuleSource = "privateAgent" + $nonClassicModuleSource = "privateAgent" + Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic." return; } - $moduleZipPath = $modulePath + ".zip"; - if (-not(Test-Path -Path $moduleZipPath)) { - Write-Verbose "Module zip not available to unzip at $moduleZipPath" + if (!$targetVersion) { + $classicModuleSource = "hostedAgentFolder" + $nonClassicModuleSource = "hostedAgentFolder" + Write-Verbose "Latest module selected which will be available as folder." return; } - Write-Verbose "Extracting zip $moduleZipPath" - $parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath") - $command = "$PSScriptRoot\7zip\7z.exe" - &$command @parameter - Write-Verbose "Extraction complete" -}) + # value for classic + @($false, $true).ForEach({ + $modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_; + if (Test-Path -Path $modulePath) { + if ($_) { + $classicModuleSource = "hostedAgentFolder" + } else { + $nonClassicModuleSource = "hostedAgentFolder" + } + + Write-Verbose "Module available as folder at $modulePath" + return; + } + + $moduleZipPath = $modulePath + ".zip"; + if (-not(Test-Path -Path $moduleZipPath)) { + if ($_) { + $classicModuleSource = "hostedAgentOthers" + } else { + $nonClassicModuleSource = "hostedAgentOthers" + } + + Write-Verbose "Module zip not available to unzip at $moduleZipPath" + return; + } + + if ($_) { + $classicModuleSource = "hostedAgentZip" + } else { + $nonClassicModuleSource = "hostedAgentZip" + } + + Write-Verbose "Extracting zip $moduleZipPath" + $parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath") + $command = "$PSScriptRoot\7zip\7z.exe" + &$command @parameter + Write-Verbose "Extraction complete" + }) +} finally { + # Telemetry + $telemetryJsonContent = @{ + targetAzurePs = $targetVersion; + classicModuleSource = $classicModuleSource; + nonClassicModuleSource = $nonClassicModuleSource + } | ConvertTo-Json -Compress + Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV2]$telemetryJsonContent" +} diff --git a/Tasks/AzurePowerShellV3/AzurePowerShell.ps1 b/Tasks/AzurePowerShellV3/AzurePowerShell.ps1 index 2ed8ee761835..16fc2f59fccc 100644 --- a/Tasks/AzurePowerShellV3/AzurePowerShell.ps1 +++ b/Tasks/AzurePowerShellV3/AzurePowerShell.ps1 @@ -181,7 +181,3 @@ finally { } Write-Host "## Script Execution Complete" Disconnect-AzureAndClearContext -authScheme $authScheme -ErrorAction SilentlyContinue - -# Telemetry -$telemetryJsonContent = @{ targetAzurePs = $targetAzurePs } | ConvertTo-Json -Compress -Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV3]$telemetryJsonContent" \ No newline at end of file diff --git a/Tasks/AzurePowerShellV3/TryMakingModuleAvailable.ps1 b/Tasks/AzurePowerShellV3/TryMakingModuleAvailable.ps1 index 10a92c351259..c834fdffde67 100644 --- a/Tasks/AzurePowerShellV3/TryMakingModuleAvailable.ps1 +++ b/Tasks/AzurePowerShellV3/TryMakingModuleAvailable.ps1 @@ -4,36 +4,68 @@ param ( $targetVersion ) -. "$PSScriptRoot\Utility.ps1" -$moduleContainerPath = Get-SavedModuleContainerPath +try { + . "$PSScriptRoot\Utility.ps1" + $moduleContainerPath = Get-SavedModuleContainerPath -if (-not(Test-Path -Path $moduleContainerPath)) { - Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic." - return; -} - -if (!$targetVersion) { - Write-Verbose "Latest module selected which will be available as folder." - return; -} - -# value for classic -@($false, $true).ForEach({ - $modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_; - if (Test-Path -Path $modulePath) { - Write-Verbose "Module available as folder at $modulePath" + if (-not(Test-Path -Path $moduleContainerPath)) { + $classicModuleSource = "privateAgent" + $nonClassicModuleSource = "privateAgent" + Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic." return; } - $moduleZipPath = $modulePath + ".zip"; - if (-not(Test-Path -Path $moduleZipPath)) { - Write-Verbose "Module zip not available to unzip at $moduleZipPath" + if (!$targetVersion) { + $classicModuleSource = "hostedAgentFolder" + $nonClassicModuleSource = "hostedAgentFolder" + Write-Verbose "Latest module selected which will be available as folder." return; } - Write-Verbose "Extracting zip $moduleZipPath" - $parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath") - $command = "$PSScriptRoot\7zip\7z.exe" - &$command @parameter - Write-Verbose "Extraction complete" -}) + # value for classic + @($false, $true).ForEach({ + $modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_; + if (Test-Path -Path $modulePath) { + if ($_) { + $classicModuleSource = "hostedAgentFolder" + } else { + $nonClassicModuleSource = "hostedAgentFolder" + } + + Write-Verbose "Module available as folder at $modulePath" + return; + } + + $moduleZipPath = $modulePath + ".zip"; + if (-not(Test-Path -Path $moduleZipPath)) { + if ($_) { + $classicModuleSource = "hostedAgentOthers" + } else { + $nonClassicModuleSource = "hostedAgentOthers" + } + + Write-Verbose "Module zip not available to unzip at $moduleZipPath" + return; + } + + if ($_) { + $classicModuleSource = "hostedAgentZip" + } else { + $nonClassicModuleSource = "hostedAgentZip" + } + + Write-Verbose "Extracting zip $moduleZipPath" + $parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath") + $command = "$PSScriptRoot\7zip\7z.exe" + &$command @parameter + Write-Verbose "Extraction complete" + }) +} finally { + # Telemetry + $telemetryJsonContent = @{ + targetAzurePs = $targetVersion; + classicModuleSource = $classicModuleSource; + nonClassicModuleSource = $nonClassicModuleSource + } | ConvertTo-Json -Compress + Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV3]$telemetryJsonContent" +}