From 1c219e2728758431b95ceeefe1804417e93ad4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ashish=20Ranjan=20=F0=9F=92=A9?= Date: Wed, 10 Jun 2020 14:14:53 +0530 Subject: [PATCH] Revert "[AzureFileCopy] Pick up latest Azure PowerShell module on Hosted agent (#13067) (#13083)" This reverts commit f93aec53156ebe37435edc62dd16fab2323e8edb. --- .../task.json | 4 +- .../task.loc.json | 4 +- Tasks/AzureFileCopyV2/AzureFileCopy.ps1 | 4 +- Tasks/AzureFileCopyV2/task.json | 4 +- Tasks/AzureFileCopyV2/task.loc.json | 4 +- Tasks/AzureFileCopyV3/AzureFileCopy.ps1 | 1 - Tasks/AzureFileCopyV3/task.json | 4 +- Tasks/AzureFileCopyV3/task.loc.json | 4 +- Tasks/AzureFileCopyV4/task.json | 4 +- Tasks/AzureFileCopyV4/task.loc.json | 4 +- .../resources.resjson/en-US/resources.resjson | 4 +- Tasks/AzurePowerShellV2/task.json | 4 +- Tasks/AzurePowerShellV2/task.loc.json | 4 +- .../resources.resjson/en-US/resources.resjson | 2 +- Tasks/AzurePowerShellV3/task.json | 4 +- Tasks/AzurePowerShellV3/task.loc.json | 4 +- Tasks/AzurePowerShellV4/task.json | 4 +- Tasks/AzurePowerShellV4/task.loc.json | 4 +- Tasks/AzurePowerShellV5/task.json | 4 +- Tasks/AzurePowerShellV5/task.loc.json | 4 +- .../VstsAzureHelpers_/PsModuleUtility.ps1 | 91 ------------------- .../VstsAzureHelpers_/VstsAzureHelpers_.psm1 | 3 - Tasks/SqlAzureDacpacDeploymentV1/task.json | 4 +- .../SqlAzureDacpacDeploymentV1/task.loc.json | 4 +- 24 files changed, 40 insertions(+), 137 deletions(-) delete mode 100644 Tasks/Common/VstsAzureHelpers_/PsModuleUtility.ps1 diff --git a/Tasks/AzureCloudPowerShellDeploymentV1/task.json b/Tasks/AzureCloudPowerShellDeploymentV1/task.json index f0b5b8de3d87..69b2c1e7506b 100644 --- a/Tasks/AzureCloudPowerShellDeploymentV1/task.json +++ b/Tasks/AzureCloudPowerShellDeploymentV1/task.json @@ -16,8 +16,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "demands": [ "azureps" diff --git a/Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json b/Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json index 082ca6fc5b9c..3c24ce0ea452 100644 --- a/Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json +++ b/Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json @@ -16,8 +16,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 index 6096ffae1d10..b5d6f7cab62f 100644 --- a/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 @@ -65,9 +65,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -. "$PSScriptRoot\Utility.ps1" -$endpoint = Get-Endpoint -connectedServiceName $connectedServiceName -Update-PSModulePathForHostedAgentWithLatestModule -Endpoint $endpoint Initialize-Azure # Import the loc strings. @@ -75,6 +72,7 @@ Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json # Load all dependent files for execution . "$PSScriptRoot\AzureFileCopyRemoteJob.ps1" +. "$PSScriptRoot\Utility.ps1" # Enabling detailed logging only when system.debug is true $enableDetailedLogging = ($env:system_debug -eq "true") diff --git a/Tasks/AzureFileCopyV2/task.json b/Tasks/AzureFileCopyV2/task.json index 887a6ca51445..c4e1a6f2a9c4 100644 --- a/Tasks/AzureFileCopyV2/task.json +++ b/Tasks/AzureFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/task.loc.json b/Tasks/AzureFileCopyV2/task.loc.json index 323ce7da3361..c00b84b125fa 100644 --- a/Tasks/AzureFileCopyV2/task.loc.json +++ b/Tasks/AzureFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 index 9d87b31d69ff..36648698655f 100644 --- a/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 @@ -68,7 +68,6 @@ if (Get-Module Az.Accounts -ListAvailable){ Initialize-AzModule -Endpoint $endpoint } else{ - Update-PSModulePathForHostedAgentWithLatestModule -Endpoint $endpoint Initialize-AzureRMModule -Endpoint $endpoint } diff --git a/Tasks/AzureFileCopyV3/task.json b/Tasks/AzureFileCopyV3/task.json index 5c4b589368c4..a6e721563b59 100644 --- a/Tasks/AzureFileCopyV3/task.json +++ b/Tasks/AzureFileCopyV3/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/task.loc.json b/Tasks/AzureFileCopyV3/task.loc.json index ead7c8ba5009..09730687e8e0 100644 --- a/Tasks/AzureFileCopyV3/task.loc.json +++ b/Tasks/AzureFileCopyV3/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/task.json b/Tasks/AzureFileCopyV4/task.json index 1baecdd89f90..dec6964e02cd 100644 --- a/Tasks/AzureFileCopyV4/task.json +++ b/Tasks/AzureFileCopyV4/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 171, - "Patch": 0 + "Minor": 170, + "Patch": 2 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/task.loc.json b/Tasks/AzureFileCopyV4/task.loc.json index 91856f901c32..0aa770cf7d0f 100644 --- a/Tasks/AzureFileCopyV4/task.loc.json +++ b/Tasks/AzureFileCopyV4/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 171, - "Patch": 0 + "Minor": 170, + "Patch": 2 }, "demands": [ "azureps" diff --git a/Tasks/AzurePowerShellV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzurePowerShellV2/Strings/resources.resjson/en-US/resources.resjson index 3b35b215561a..a55aacdb13e2 100644 --- a/Tasks/AzurePowerShellV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzurePowerShellV2/Strings/resources.resjson/en-US/resources.resjson @@ -17,9 +17,9 @@ "loc.input.label.ScriptArguments": "Script Arguments", "loc.input.help.ScriptArguments": "Additional parameters to pass to PowerShell. Can be either ordinal or named parameters.", "loc.input.label.TargetAzurePs": "Azure PowerShell Version", - "loc.input.help.TargetAzurePs": "In case of hosted agents, the supported Azure PowerShell Versions are: 2.1.0, 3.8.0, 4.2.1, 5.1.1 and 6.7.0(Hosted VS2017 Queue).\nTo pick the latest version available on the agent, select \"Latest installed version\".\n\nFor private agents you can specify preferred version of Azure PowerShell using \"Specify version\"", + "loc.input.help.TargetAzurePs": "In case of hosted agents, the supported Azure PowerShell Versions are: 2.1.0, 3.8.0, 4.2.1 and 5.1.1(Hosted VS2017 Queue), 3.6.0(Hosted Queue).\nTo pick the latest version available on the agent, select \"Latest installed version\".\n\nFor private agents you can specify preferred version of Azure PowerShell using \"Specify version\"", "loc.input.label.CustomTargetAzurePs": "Preferred Azure PowerShell Version", - "loc.input.help.CustomTargetAzurePs": "Preferred Azure PowerShell Version needs to be a proper semantic version eg. 1.2.3. Regex like 2.\\*,2.3.\\* is not supported. The Hosted VS2017 Pool currently supports Azure module versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1 and AzureRM module versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1, 6.7.0", + "loc.input.help.CustomTargetAzurePs": "Preferred Azure PowerShell Version needs to be a proper semantic version eg. 1.2.3. Regex like 2.\\*,2.3.\\* is not supported. The Hosted VS2017 Pool currently supports versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1", "loc.messages.InvalidScriptArguments0": "Invalid script arguments '{0}'. Line breaks are not allowed.", "loc.messages.InvalidScriptPath0": "Invalid script path '{0}'. Invalid path characters specified.", "loc.messages.InvalidAzurePsVersion": "The Azure PowerShell version '{0}' specified is not in the correct format. Please check the format. An example of correct format is 1.0.1", diff --git a/Tasks/AzurePowerShellV2/task.json b/Tasks/AzurePowerShellV2/task.json index 67e4f87c1e5f..8a9d83fdc5a5 100644 --- a/Tasks/AzurePowerShellV2/task.json +++ b/Tasks/AzurePowerShellV2/task.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "demands": [ "azureps" diff --git a/Tasks/AzurePowerShellV2/task.loc.json b/Tasks/AzurePowerShellV2/task.loc.json index ec165b987b94..1284bb1ef3b6 100644 --- a/Tasks/AzurePowerShellV2/task.loc.json +++ b/Tasks/AzurePowerShellV2/task.loc.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "demands": [ "azureps" diff --git a/Tasks/AzurePowerShellV3/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzurePowerShellV3/Strings/resources.resjson/en-US/resources.resjson index a9bb8e5fe11b..0d52333c6f9b 100644 --- a/Tasks/AzurePowerShellV3/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzurePowerShellV3/Strings/resources.resjson/en-US/resources.resjson @@ -23,7 +23,7 @@ "loc.input.label.FailOnStandardError": "Fail on Standard Error", "loc.input.help.FailOnStandardError": "If this is true, this task will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream.", "loc.input.label.TargetAzurePs": "Azure PowerShell Version", - "loc.input.help.TargetAzurePs": "In case of hosted agents, the supported Azure PowerShell Versions are: 2.1.0, 3.8.0, 4.2.1, 5.1.1 and 6.7.0(Hosted VS2017 Queue).\nTo pick the latest version available on the agent, select \"Latest installed version\".\n\nFor private agents you can specify preferred version of Azure PowerShell using \"Specify version\"", + "loc.input.help.TargetAzurePs": "In case of hosted agents, the supported Azure PowerShell Versions are: 2.1.0, 3.8.0, 4.2.1, 5.1.1 and 6.7.0(Hosted VS2017 Queue), 3.6.0(Hosted Queue).\nTo pick the latest version available on the agent, select \"Latest installed version\".\n\nFor private agents you can specify preferred version of Azure PowerShell using \"Specify version\"", "loc.input.label.CustomTargetAzurePs": "Preferred Azure PowerShell Version", "loc.input.help.CustomTargetAzurePs": "Preferred Azure PowerShell Version needs to be a proper semantic version eg. 1.2.3. Regex like 2.\\*,2.3.\\* is not supported. The Hosted VS2017 Pool currently supports Azure module versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1 and AzureRM module versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1, 6.7.0", "loc.messages.InvalidScriptArguments0": "Invalid script arguments '{0}'. Line breaks are not allowed.", diff --git a/Tasks/AzurePowerShellV3/task.json b/Tasks/AzurePowerShellV3/task.json index 30c84d1abe62..9a13fa4bb85e 100644 --- a/Tasks/AzurePowerShellV3/task.json +++ b/Tasks/AzurePowerShellV3/task.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "releaseNotes": "Added support for Fail on standard error and ErrorActionPreference", "demands": [ diff --git a/Tasks/AzurePowerShellV3/task.loc.json b/Tasks/AzurePowerShellV3/task.loc.json index 4a44e1a6a91a..a111609dbfad 100644 --- a/Tasks/AzurePowerShellV3/task.loc.json +++ b/Tasks/AzurePowerShellV3/task.loc.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 3 }, "releaseNotes": "ms-resource:loc.releaseNotes", "demands": [ diff --git a/Tasks/AzurePowerShellV4/task.json b/Tasks/AzurePowerShellV4/task.json index c5cfecd34209..a172d4bbf7e0 100644 --- a/Tasks/AzurePowerShellV4/task.json +++ b/Tasks/AzurePowerShellV4/task.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 171, - "Patch": 0 + "Minor": 168, + "Patch": 2 }, "releaseNotes": "Added support for Az Module and cross platform agents.", "groups": [ diff --git a/Tasks/AzurePowerShellV4/task.loc.json b/Tasks/AzurePowerShellV4/task.loc.json index e819f1f13c3a..6b4087a45c5c 100644 --- a/Tasks/AzurePowerShellV4/task.loc.json +++ b/Tasks/AzurePowerShellV4/task.loc.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 171, - "Patch": 0 + "Minor": 168, + "Patch": 2 }, "releaseNotes": "ms-resource:loc.releaseNotes", "groups": [ diff --git a/Tasks/AzurePowerShellV5/task.json b/Tasks/AzurePowerShellV5/task.json index 597479615e6f..c35ff6cb99c9 100644 --- a/Tasks/AzurePowerShellV5/task.json +++ b/Tasks/AzurePowerShellV5/task.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 171, - "Patch": 0 + "Minor": 170, + "Patch": 1 }, "releaseNotes": "Added support for Az Module and cross platform agents.", "groups": [ diff --git a/Tasks/AzurePowerShellV5/task.loc.json b/Tasks/AzurePowerShellV5/task.loc.json index 06c1fec68d49..aeb0185cc3d8 100644 --- a/Tasks/AzurePowerShellV5/task.loc.json +++ b/Tasks/AzurePowerShellV5/task.loc.json @@ -17,8 +17,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 171, - "Patch": 0 + "Minor": 170, + "Patch": 1 }, "releaseNotes": "ms-resource:loc.releaseNotes", "groups": [ diff --git a/Tasks/Common/VstsAzureHelpers_/PsModuleUtility.ps1 b/Tasks/Common/VstsAzureHelpers_/PsModuleUtility.ps1 deleted file mode 100644 index c110a927ab96..000000000000 --- a/Tasks/Common/VstsAzureHelpers_/PsModuleUtility.ps1 +++ /dev/null @@ -1,91 +0,0 @@ -function Update-PSModulePathForHostedAgentWithLatestModule -{ - [CmdletBinding()] - param( - [object] $Endpoint - ) - - Trace-VstsEnteringInvocation $MyInvocation - try - { - $authenticationScheme = $Endpoint.Auth.Scheme - - if ($authenticationScheme -eq "ServicePrincipal" -or - $authenticationScheme -eq "ManagedServiceIdentity") - { - Write-Verbose "Updating PSModulePath with latest AzureRM module." - $latestAzureRmModulePath = Get-LatestAzureRmModulePath - - if (![string]::IsNullOrEmpty($latestAzureRmModulePath)) - { - $env:PSModulePath = "$latestAzureRmModulePath;$env:PSModulePath" - } - else - { - Write-Verbose "Latest AzureRM module path is null or empty." - } - } - - } - finally - { - Write-Verbose "The updated value of the PSModulePath is: $($env:PSModulePath)" - Trace-VstsLeavingInvocation $MyInvocation - } -} - -function Get-LatestAzureRmModulePath -{ - [CmdletBinding()] - param() - - Trace-VstsEnteringInvocation $MyInvocation - $hostedAgentAzureModulesPath = Join-Path -Path $env:SystemDrive -ChildPath "modules" - $latestAzureRmModulePath = "" - try - { - if ($(Test-Path $hostedAgentAzureModulesPath)) - { - $regexToMatch = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList "^azurerm_[0-9]+\.[0-9]+\.[0-9]+$" - $regexToExtract = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList "[0-9]+\.[0-9]+\.[0-9]+$" - $maxVersion = [version] "0.0.0" - - $moduleFolders = Get-ChildItem -Directory -Path $hostedAgentAzureModulesPath | Where-Object { $regexToMatch.IsMatch($_.Name) } - - foreach ($moduleFolder in $moduleFolders) - { - $moduleVersion = [version] $($regexToExtract.Match($moduleFolder.Name).Groups[0].Value) - - if ($moduleVersion -gt $maxVersion) - { - $modulePath = [System.IO.Path]::Combine($moduleFolder.FullName,"AzureRM\$moduleVersion\AzureRM.psm1") - - if (Test-Path -LiteralPath $modulePath -PathType Leaf) - { - $maxVersion = $moduleVersion - $latestAzureRmModulePath = $moduleFolder.FullName - } - else - { - Write-Verbose "A folder matching the module folder pattern was found at $($moduleFolder.FullName) but didn't contain a valid module file" - } - } - } - } - else - { - Write-Verbose "Hosted Agent Azure modules path '$hostedAgentAzureModulesPath' does not exist." - } - - return $latestAzureRmModulePath - } - catch - { - Write-Verbose "Get-LatestAzureRmModulePath: Exception: $($_.Exception.Message)" - $latestAzureRmModulePath = "" - } - finally - { - Trace-VstsLeavingInvocation $MyInvocation - } -} \ No newline at end of file diff --git a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 index 9db66d73278f..3eae036ee3e9 100644 --- a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 +++ b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 @@ -21,7 +21,6 @@ Add-Tls12InSession . $PSScriptRoot/ImportFunctions.ps1 . $PSScriptRoot/InitializeAzureRMFunctions.ps1 . $PSScriptRoot/InitializeAzModuleFunctions.ps1 -. $PSScriptRoot/PsModuleUtility.ps1 # This is the only public function. function Initialize-Azure { @@ -74,5 +73,3 @@ Export-ModuleMember -Function Remove-EndpointSecrets Export-ModuleMember -Function Initialize-AzureRMModule Export-ModuleMember -Function Initialize-AzModule Export-ModuleMember -Function Disconnect-AzureAndClearContext -Export-ModuleMember -Function Update-PSModulePathForHostedAgentWithLatestModule - diff --git a/Tasks/SqlAzureDacpacDeploymentV1/task.json b/Tasks/SqlAzureDacpacDeploymentV1/task.json index 61912c28ae90..5ad27beef0ff 100644 --- a/Tasks/SqlAzureDacpacDeploymentV1/task.json +++ b/Tasks/SqlAzureDacpacDeploymentV1/task.json @@ -16,8 +16,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "sqlpackage" diff --git a/Tasks/SqlAzureDacpacDeploymentV1/task.loc.json b/Tasks/SqlAzureDacpacDeploymentV1/task.loc.json index 3f202feff520..fa2382c839ee 100644 --- a/Tasks/SqlAzureDacpacDeploymentV1/task.loc.json +++ b/Tasks/SqlAzureDacpacDeploymentV1/task.loc.json @@ -16,8 +16,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 171, - "Patch": 0 + "Minor": 167, + "Patch": 4 }, "demands": [ "sqlpackage"