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

[BUG]: Powershell@2 Impossible to ignore specific warning output #20851

Open
4 of 7 tasks
arc-hbas opened this issue Feb 12, 2025 · 0 comments
Open
4 of 7 tasks

[BUG]: Powershell@2 Impossible to ignore specific warning output #20851

arc-hbas opened this issue Feb 12, 2025 · 0 comments
Assignees
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug triage

Comments

@arc-hbas
Copy link

New issue checklist

Task name

Powershell

Task version

2

Issue Description

When using the PowerShell@2 task and enabling showWarnings, it becomes impossible to specifically ignore a single warning, even if WarningAction is set to Ignore or SilentlyContinue. Other "hacks", such as using redirect operator 3> to redirect warning output stream to file or $null, have not been successful to workaround this issue. This potentially causes massive log clutter when you still want to surface warning output to the pipeline summary view, but would like to disregard some of the non-important ones.

Running below example YAML pipeline, all of the warnings are still surfaced:

Image

Image

I thought surely the 3> redirect would work, but alas it doesn't. Thus far I have been unable to find any sort of workaround. Warnings are helpful, but only when they're relevant. Sometimes we call system level or pre-built cmdlets and cannot expect them to only print out relevant warnings (from our perspective at least).

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

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows

Relevant log output

...
WARNING: a) Default: Shows = true & Expected = true
##[warning]a) Default: Shows = true & Expected = true
##[warning]b) SilentlyContinue: Shows = true & Expected = false
##[warning]c) Ignore: Shows = true & Expected = false
##[warning]d) 3> redirect $null: Shows = true & Expected = false
##[warning]e) 3> redirect file: Shows = true & Expected = false


Finishing: Test PS

Full task logs with system.debug enabled

No response

Repro steps

trigger:
- none

pool:
  vmImage: windows-latest

steps:

- task: PowerShell@2
  displayName: Test PS
  inputs:
    targetType: 'inline'
    showWarnings: true
    script: |      
      # Should print and does
      Write-Warning "a) Default: Shows = true & Expected = true" 

      # Should NOT print but does
      Write-Warning "b) SilentlyContinue: Shows = true & Expected = false" -WarningAction SilentlyContinue

      # Should NOT print but does
      Write-Warning "c) Ignore: Shows = true & Expected = false" -WarningAction Ignore

      # Should NOT print but does
      Write-Warning "d) 3> redirect `$null: Shows = true & Expected = false" 3> $null

      # Should NOT print but does
      Write-Warning "e) 3> redirect file: Shows = true & Expected = false" 3> out.txt
@arc-hbas arc-hbas added the bug label Feb 12, 2025
@sanjuyadav24 sanjuyadav24 added Area: ABTT Akvelon Build Tasks Team area of work and removed Area: Release labels Feb 24, 2025
@sanjuyadav24 sanjuyadav24 self-assigned this Feb 24, 2025
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 triage
Projects
None yet
Development

No branches or pull requests

2 participants