Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated PowerShellV2 task changes Powershell behavior for users. #14054

Closed
MattGal opened this issue Dec 10, 2020 · 7 comments
Closed

Updated PowerShellV2 task changes Powershell behavior for users. #14054

MattGal opened this issue Dec 10, 2020 · 7 comments
Assignees
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug Task: PowerShell

Comments

@MattGal
Copy link
Member

MattGal commented Dec 10, 2020

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: PowerShell

Environment

Not applicable - Any Windows

Issue Description

This change broke our pipelines' usage of the PowerShell task, specifically by changing the scope of some variables.

From reading the arguments put forth by the change I expect we will not be able to convince you to put this back, but I'm putting this info here in case it's relevant to other users and to raise awareness.

Contents of entrypoint.ps1

param(
  [Parameter(Mandatory=$false)][string] $Variable1= "stuff",
  [Parameter(Mandatory=$false)][string] $Variable2 = "things",
  [Parameter(Mandatory=$false)][string] $Variable3 = "pizza"
)

. $PSScriptRoot\other-script.ps1

Write-Host "Hello from entrypoint Script! v1 = $Variable1, v2 = $Variable2, v3 = $Variable3"

MethodInOtherScript("trying this")

Contents of other-script.ps1:

function MethodInOtherScript([string]$arg)  { 
  Write-Output "Function called, with arg '$arg'"

  try {
    Write-Output "Not Global"
    Get-Variable Variable1
    Get-Variable Variable2
    Get-Variable Variable3
   
    Write-Output "Global"
    Get-Variable Variable1 -Scope Global
    Get-Variable Variable2 -Scope Global
    Get-Variable Variable3 -Scope Global
  }
  catch {
    Write-Host $_
    ExitWithExitCode 1
  }
}
powershell -NoProfile -NonInteractive -Command ". .\entrypoint.ps1"

Hello from entrypoint Script! v1 = stuff, v2 = things, v3 = pizza
Function called, with arg 'trying this'
Not Global

Name                           Value
----                           -----
Variable1                      stuff
Variable2                      things
Variable3                      pizza
Global
Variable1                      stuff
Variable2                      things
Variable3                      pizza

powershell -NoProfile -NonInteractive -Command "& .\entrypoint.ps1"
Hello from entrypoint Script! v1 = stuff, v2 = things, v3 = pizza
Function called, with arg 'trying this'
Not Global

Name                           Value
----                           -----
Variable1                      stuff
Variable2                      things
Variable3                      pizza
Global
Get-Variable : Cannot find a variable with the name 'Variable1'.
At D:\Git\mattgal-experimental\other-script.ps1:11 char:5
+     Get-Variable Variable1 -Scope Global
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Variable1:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand

Get-Variable : Cannot find a variable with the name 'Variable2'.
At D:\Git\mattgal-experimental\other-script.ps1:12 char:5
+     Get-Variable Variable2 -Scope Global
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Variable2:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand

Get-Variable : Cannot find a variable with the name 'Variable3'.
At D:\Git\mattgal-experimental\other-script.ps1:13 char:5
+     Get-Variable Variable3 -Scope Global
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Variable3:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand
@anatolybolshakov
Copy link
Contributor

Hi @MattGal we are working on the fix for this issue currently, we will let you know once it's resolved to verify

@EzzhevNikita
Copy link
Contributor

Hey @MattGal, we have reverted this change and delivered hotfix for this issue. Could you please check and confirm that it works as expected now?

@MattGal
Copy link
Member Author

MattGal commented Dec 10, 2020

Hey @MattGal, we have reverted this change and delivered hotfix for this issue. Could you please check and confirm that it works as expected now?

Awesome, thank you! I didn't expect this outcome. For the parts of our infrastructure this broke which we noticed I think we've found a workaround but I'll keep an eye out for anything else unusual.

@MattGal
Copy link
Member Author

MattGal commented Dec 10, 2020

@EzzhevNikita at least as of this morning, I am still seeing 2.179.0 get used and that it still contains this behavior.

@EzzhevNikita
Copy link
Contributor

@MattGal Could you please share you organisation name? I'll check if the fix was applied for it

@MattGal
Copy link
Member Author

MattGal commented Dec 10, 2020

Sure, it's https://devdiv.visualstudio.com/

@EzzhevNikita
Copy link
Contributor

Hotfix was provided and @MattGal confirmed in Teams that updated task appeared in his org. So closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug Task: PowerShell
Projects
None yet
Development

No branches or pull requests

3 participants