我如何使用powereshell在Jenkinsfile中打印当前工作目录

我已经尝试过了

powershell( returnStdout: true,script: 'Get-Location' )

但是我在日志中得到的只是空白行,值得说明像Write-Output这样的命令。

wuyuesuper 回答:我如何使用powereshell在Jenkinsfile中打印当前工作目录

由于此语法返回了输出流,即Powershell输出的流1,而没有将其打印到控制台,因此您需要将stdout存储在变量中,并在Jenkinsfile中显式打印。

currentDir = powershell(returnStdout: true,script: 'Get-Location')
println(currentDir)

请参见Microsoft PowerShell Support for Pipeline

本文链接:https://www.f2er.com/3097688.html

大家都在问