microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[BUG]: PowerShell Task 2.227.0 throws an exception #18896

Closed verback2308 closed 1 year ago

verback2308 commented 1 year ago

Task name

PowerShell

Task version

2.227.0

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows Server 2012

Task log

Starting: Generate build and revision
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.227.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
##[error]At C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\errors.ps1:1 char:1
+ class ArgsSanitizingException : Exception {
+ ~~~~~
The 'class' keyword is not supported in this version of the language.

Finishing: Generate build and revision

Relevant log output

##[debug]Evaluating condition for step: 'Generate build and revision'
##[debug]Evaluating: SucceededNode()
##[debug]Evaluating SucceededNode:
##[debug]=> True
##[debug]Result: True
Starting: Generate build and revision
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.227.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\powershell.ps1 : At C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\errors.ps1:1 char:1
##[debug]+ class ArgsSanitizingException : Exception {
##[debug]+ ~~~~~
##[debug]The 'class' keyword is not supported in this version of the language.
##[debug]
##[debug]
##[debug]At line:1 char:1
##[debug]+ . 'C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2. ...
##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : ParserError: (:) [powershell.ps1], ParseExceptio    n
##[debug]    + FullyQualifiedErrorId : ReservedKeywordNotAllowed,powershell.ps1
##[debug] 
##[debug]Script stack trace:
##[debug]at <ScriptBlock>, C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\helpers.ps1: line 1
##[debug]at <ScriptBlock>, C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\powershell.ps1: line 4
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Management.Automation.ParseException: At C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\errors.ps1:1 char:1
##[debug]+ class ArgsSanitizingException : Exception {
##[debug]+ ~~~~~
##[debug]The 'class' keyword is not supported in this version of the language.
##[debug]
##[debug]
##[debug]   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[debug]   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
##[debug]   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
##[debug]   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
##[debug]   at System.Management.Automation.CommandProcessorBase.Complete()
##[error]At C:\vsts-agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.227.0\errors.ps1:1 char:1
+ class ArgsSanitizingException : Exception {
+ ~~~~~
The 'class' keyword is not supported in this version of the language.

Aditional info

This task started to fail after today's update to the 2.227.0 version. I've found a workaround to restore our CI/CD process by replacing files in C:\vsts-agent_work_tasks\PowerShell_XXX\2.227.0 with a content of a previous version.


Here is a $psversiontable output:
Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.20719
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

Here is a task:

- task: PowerShell@2
  displayName: 'Generate build and revision'
  inputs:
    targetType: 'inline'
    script: |
      cd $(Build.SourcesDirectory)
      $commitDate = git show --no-patch --no-notes --pretty=%cI $(Build.SourceVersion)
      $commitDate = & "$(Build.SourcesDirectory)\Tools\timeconverter.exe" $commitDate
      $cDate,$cTime = $commitDate.split('.')
      echo "##vso[task.setvariable variable=CommitDate;]$cDate"
      echo "##vso[task.setvariable variable=CommitTime;]$cTime"
c0shea commented 1 year ago

This has broken our builds today, too.

verback2308 commented 1 year ago

This has broken our builds today, too.

The good news is that there is a temporary workaround

c0shea commented 1 year ago

Same as #18895

c0shea commented 1 year ago

This has broken our builds today, too.

The good news is that there is a temporary workaround

Turns out the workaround doesn't work if you use the classic editor (like we do) and not YAML for the pipelines. I can only specify the task should use 1. or 2. but not 2.226.2 specifically.

nanny07 commented 1 year ago

Turns out the workaround doesn't work if you use the classic editor (like we do) and not YAML for the pipelines. I can only specify the task should use 1. or 2. but not 2.226.2 specifically.

Exactly, this need to be fixed ASAP

verback2308 commented 1 year ago

This has broken our builds today, too.

The good news is that there is a temporary workaround

Turns out the workaround doesn't work if you use the classic editor (like we do) and not YAML for the pipelines. I can only specify the task should use 1. or 2. but not 2.226.2 specifically.

Have you tried to replace the content of the 2.227.0 folder with the content of the 2.226.2 folder?

KonstantinTyukalov commented 1 year ago

We apologize for the issue caused. We have restored the previous version of the task. Could you please check if the problem persists? Thank you

xavier-dourille commented 1 year ago

We apologize for the issue caused. We have restored the previous version of the task. Could you please check if the problem persists? Thank you

The problem persists!

alexandrelugand commented 1 year ago

At this time, no change. The agent always use 2.227.0 version.

Kyle-270 commented 1 year ago

It is currently running 2.226.2 fine for us using classic pipelines on a self-hosted agent.

Task : PowerShell Description : Run a PowerShell script on Linux, macOS, or Windows Version : 2.226.2 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell

EDIT: It worked fine for our build pipeline and was using 2.226.2, but our release pipeline which is ran on a different agent is still having issues and trying to use version 2.227.0

KonstantinTyukalov commented 1 year ago

@verback2308 @alexandrelugand @nanny07 @Kyle-270 the issue should not exist at this time. Please let me know if you are still facing with this problem

nanny07 commented 1 year ago

@KonstantinTyukalov now it works again as I said in the other thread. Thanks again

KonstantinTyukalov commented 1 year ago

Fixed here: https://github.com/microsoft/azure-pipelines-tasks/pull/18904

KonstantinTyukalov commented 1 year ago

Closing this as fixed. Please ping me if someone still have this issue