简体   繁体   English

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

[英]How can I print the current working directory in a Jenkinsfile using powereshell

I've tried this我试过这个

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

but all I get in the logs is a blank line, worth stating commands like Write-Output work.但我在日志中得到的只是一个空白行,值得说明诸如Write-Output类的命令工作。

Since this syntax returns the output stream, ie stream 1 of Powershell output without printing it to the console, you need to store the stdout in a variable and print it explicitly in the Jenkinsfile. Since this syntax returns the output stream, ie stream 1 of Powershell output without printing it to the console, you need to store the stdout in a variable and print it explicitly in the Jenkinsfile.

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

See Microsoft PowerShell Support for Pipeline .请参阅Microsoft PowerShell 对 Pipeline 的支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM