Skip to content

Commit

Permalink
Removing Azure and AzureRM 2.1.0 from hosted agent (#10787)
Browse files Browse the repository at this point in the history
* Removing Azure and AzureRM 2.1.0 from hosted agent

* adding PreJobExecutionAzurePowerShell.ps1

* Resolving ccheck

* Resolving check

* resolving check

* resolving check

* resolving check

* resolving check

* resolving test check

* resolving check

* checking

* resolving check:

* Increasing patch version

* updating patch

* Resolving comments

* resolving check

* resolving comments

* resolving test check

* resolving comments

* correcting path

* removing unnecessary space

* changing minor and patch versions
  • Loading branch information
20shivangi authored Aug 5, 2019
1 parent 497023d commit 245f88d
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 4 deletions.
1 change: 1 addition & 0 deletions Tasks/AzurePowerShellV4/AzurePowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if ($targetAzurePs -eq $latestVersion) {

$serviceName = Get-VstsInput -Name ConnectedServiceNameARM -Require
$endpoint = Get-VstsEndpoint -Name $serviceName -Require
$env:PSModulePath = Get-VstsTaskVariable -Name "AZ_PS_MODULE_PATH"

Update-PSModulePathForHostedAgent -targetAzurePs $targetAzurePs

Expand Down
21 changes: 21 additions & 0 deletions Tasks/AzurePowerShellV4/PreJobExecutionAzurePowerShell.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$azPSModulePath = $env:PSModulePath

if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
}

if ($azPSModulePath.split(";") -contains $azureModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $azPSModulePath"
}

Set-VstsTaskVariable -Name 'AZ_PS_MODULE_PATH' -Value $azPSModulePath
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/DoesNotFailOnStandardError.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/DoesNotUnravelOutput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/FailsForNativeCommandError.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/PerformsBasicFlow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Register-Mock Initialize-AzModule
Register-Mock Get-VstsEndpoint { @{auth = @{ scheme = "ServicePrincipal" }} }
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = & $PSScriptRoot\..\AzurePowerShell.ps1
Expand Down
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/RedirectsErrors.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Register-Mock Update-PSModulePathForHostedAgent
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Arrange the mock task SDK module.
New-Module -Name VstsTaskSdk -ScriptBlock {
Expand Down
3 changes: 3 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/ThrowsForInvalidVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Register-Mock Get-VstsInput { "FilePath" } -- -Name ScriptType -Require
Register-Mock Get-VstsInput { "foobar.ps1" } -- -Name ScriptPath
Register-Mock Get-VstsInput { "OtherVersion" } -- -Name TargetAzurePs
Register-Mock Get-VstsInput { "x.y.z" } -- -Name CustomTargetAzurePs
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable
Register-Mock Get-VstsEndpoint

# Act/Assert.
Assert-Throws {
Expand Down
2 changes: 2 additions & 0 deletions Tasks/AzurePowerShellV4/Tests/ValidateInlineScriptFlow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Register-Mock Initialize-AzModule
Register-Mock Remove-EndpointSecrets
Register-Mock Disconnect-AzureAndClearContext
Register-Mock Get-VstsEndpoint
Register-Mock Get-VstsTaskVariable
Register-Mock Set-VstsTaskVariable

# Act.
$actual = @( & $PSScriptRoot\..\AzurePowerShell.ps1 )
Expand Down
12 changes: 10 additions & 2 deletions Tasks/AzurePowerShellV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 154,
"Patch": 5
"Minor": 156,
"Patch": 0
},
"preview": true,
"releaseNotes": "Added support for Az Module and cross platform agents.",
Expand Down Expand Up @@ -143,6 +143,14 @@
}
],
"instanceNameFormat": "Azure PowerShell script: $(ScriptType)",
"prejobexecution": {
"PowerShell3": {
"target": "PreJobExecutionAzurePowerShell.ps1",
"platforms": [
"windows"
]
}
},
"execution": {
"PowerShell3": {
"target": "azurepowershell.ps1",
Expand Down
12 changes: 10 additions & 2 deletions Tasks/AzurePowerShellV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 154,
"Patch": 5
"Minor": 156,
"Patch": 0
},
"preview": true,
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down Expand Up @@ -143,6 +143,14 @@
}
],
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
"prejobexecution": {
"PowerShell3": {
"target": "PreJobExecutionAzurePowerShell.ps1",
"platforms": [
"windows"
]
}
},
"execution": {
"PowerShell3": {
"target": "azurepowershell.ps1",
Expand Down

0 comments on commit 245f88d

Please sign in to comment.