Azure-pipelines-tasks: PowerShell Script - No debug output

Created on 25 Oct 2018  路  7Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

TFS on-premises : 2018 update 2 with private agents :
Agent.OS : Windows_NT
Agent.OSVersion : 10.0.14393
Agent.Version : 2.140.0

Issue Description

I create a PowerShell script with some "Write-Debug" entries.

I run this script with the TFS task "PowerShell" (Version 2.129.0) type of the script: "File Path".

When you start a build definition with the variable "system.debug" set at "true" the build log do not display the debug entries.

Same issue with the type of the script: "Inline Script".

Core enhancement

All 7 comments

system.debug enables verbose-output so you should try using 'Write-Verbose' instead

@JohannesDrexler I have just try with 'Write-Verbose' and it doesn't works :-/

Ok i looked where i last used this and found that i added some arguments

Here is the script that can be used to reproduce the behavior:

[cmdletbinding()]
param()

write-verbose "test test 123"

When calling the script i added to the arguments: -verbose:$$(system.debug)

Thanks @JohannesDrexler

But should not this argument be native to the task when "system.debug" is set at "true" ? @kmkumaran

Adding @ericsciple & @bryanmacfarlane to comment on the behavior.

system.debug is for troubleshooting Pipelines infrastructure. I think tying PowerShell's log level to that variable isn't a good pattern in general. (There's a slippery slope to other ecosystems, as well. At a minimum we'd have to do Node.js since it's another first-class scripting environment. And then would we end up doing it for Python, Java, etc.?)

That said - it's no problem if an individual Pipelines user wants to key off that variable as someone did in this thread.

I also expected that Write-Debug would wite to pipeline's debug output.

Was this page helpful?
0 / 5 - 0 ratings