[英]Jenkins Execute Windows batch command fails for file change
I am trying to change text in a config file using Jenkins Windows batch command but its giving the following error. 我正在尝试使用Jenkins Windows批处理命令更改配置文件中的文本,但它给出以下错误。
(Get-Content config_qa.properties ) | {$_ -replace "test123", "test"} | Set-Content config_qa.properties
Ran the above in jenkins windows batch command. 在jenkins Windows批处理命令中运行以上命令。 below is the error message.
下面是错误消息。
'{$_' 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
Thanks 谢谢
Are you sure you didn't miss WHERE operator (after first pipe)? 您确定没有错过WHERE运算符(在第一个管道之后)吗? Like:
喜欢:
(Get-Content config_qa.properties ) | where {$_ -replace "test123", "test"} | Set-Content config_qa.properties
EDIT: Also, you need to make sure that Jenkins is trying to run this in PowerShell, not Windows batch (default) 编辑:另外,您需要确保Jenkins尝试在PowerShell中而不是Windows批处理中运行它(默认)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.