powershell - 该字符串缺少终止符:“。powershell jenkins
问题描述
尝试自动化 powershell 行时遇到一个奇怪的问题。
在我的 powershell 上它可以工作,但在 Jenkins 管道下它总是说以下错误:
The string is missing the terminator: ".
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
我的代码行:
powershell $mybranch = (get-content F:\software\branchname) -replace '.*?/'; new-Item -ItemType Directory -Force -Path "\\myserver\sw\software\rs\2020-RC1_$branchname"; copy-item -path "E:\Temp\2020-07-22_1.1.1-RC1_$branchname.zip" -destination "\\myserver\sw\software\rs\2020-RC1_$branchname\"
解决方案
它是双引号之前的尾随反斜杠… -destination "\\myserver\sw\software\rs\2020-RC1_$branchname\"
。加倍。
例子:
powershell -noprofile dir "packages\"
The string is missing the terminator: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
powershell -noprofile dir "packages\\"
Directory: D:\bat\packages Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 01.06.2020 10:41 com.company.sft
推荐阅读
- kubernetes - Kubernetes 集群中的请求缓冲
- asp.net - 403 禁止访问在 IIS 上托管的 asp.net 网站上使用 ssl 的图像被拒绝
- python - 将直方图箱添加在一起并绘制图形
- maven - Maven 插件中与 Eclipse Sisu/Guice 的自定义绑定
- python - tkinter 中的 scroll_text.insert 在程序完成后运行
- python - QTreeView/QFileSystemModel - 比较文件和显示颜色
- javascript - 在css中将图像url作为背景导入时出现Webpack错误
- javascript - 如何在使用 .map() 呈现的按钮之间切换 CSS 类
- google-analytics - 为什么 Google Analytics(分析)显示旧的事件类别?
- javascript - 使用 for 的 Javascript 中位数