繁体   English   中英

Jenkins执行Windows批处理命令无法更改文件

[英]Jenkins Execute Windows batch command fails for file change

我正在尝试使用Jenkins Windows批处理命令更改配置文件中的文本,但它给出以下错误。

(Get-Content config_qa.properties )  | {$_ -replace "test123", "test"}   | Set-Content config_qa.properties 

在jenkins Windows批处理命令中运行以上命令。 下面是错误消息。

'{$_' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Execute Windows batch command' marked build as failure
[workspace] $ cmd /c call C:\windows\TEMP\hudson2235664364282200461.bat

谢谢

您确定没有错过WHERE运算符(在第一个管道之后)吗? 喜欢:

(Get-Content config_qa.properties ) | where {$_ -replace "test123", "test"} | Set-Content config_qa.properties

编辑:另外,您需要确保Jenkins尝试在PowerShell中而不是Windows批处理中运行它(默认)

暂无
暂无

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

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