【发布时间】:2019-01-07 20:07:42
【问题描述】:
我尝试了不同的方法来逃避“程序文件”中的空间,但这不起作用。这部分执行后,我在 Jenkins 中收到以下错误:
powershell.exe : FileStream 被要求打开一个不是文件的设备。如需对“com1:”或“lpt1:”等设备的支持,请致电 At C:\web\JenkinsMaster\workspace\XXX@tmp\durable-d3011838\powershellWrapper.ps1:5 字符:3 + & powershell -NoProfile -NonInteractive -ExecutionPolicy 绕过 -Fi ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (FileStream was ... 'lpt1:', call :String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError CreateFile,然后使用将操作系统句柄作为 IntPtr 的 FileStream 构造函数。
CategoryInfo : OpenError: (:) [Out-File], NotSupportedException
FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
PSComputerName : XXXXX
powershell script: '''
$pass = ConvertTo-SecureString -AsPlainText "XXXX" -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList "XXXX",$pass
$sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$session = New-PSSession -ComputerName XXXXXXXX -UseSSL -Credential $cred -SessionOption $sessionOption
Copy-Item $env:WORKSPACE\\* -Destination "C:\\data\\install\\" -Filter *TEST* -Recurse -Force -Verbose -ToSession $session
$filename = $env:JOB_NAME + "_" + $env:BUILD_DISPLAY_NAME + "_wwwroot.7z"
Invoke-Command -Session $session -ScriptBlock {cmd /c "C:\\Program Files\\7-Zip\\7z.exe\\" x C:\\Data\\Install\\$filename -oC:\\data\\install\\test -aoa >NUL}
Remove-PSSession $session
Exit-PSSession
'''
如果我将 Invoke-Command 更改为以下内容,则 Program Files 目录似乎已正确解析,但变量 $filename 不再解析。
Invoke-Command -Session $session -ScriptBlock {cmd /c \'"C:\\Program Files\\7-Zip\\7z.exe" x C:\\Data\\Install\\$filename -oC:\\data\\install\\test -aoa >NUL'}
powershell.exe : NotSpecified: (:String) [], RemoteException At C:\web\Jenkins\workspace\XXX@tmp\durable-53dbead2\powershellWrapper.ps1:5 字符:3 + & powershell -NoProfile -NonInteractive -ExecutionPolicy 绕过 -Fi ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (NotSpecified: (...RemoteException:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
- CategoryInfo : NotSpecified: (:String) [], RemoteException
- FullyQualifiedErrorId : NativeCommandError
- PSComputerName : XXXXX
错误:系统找不到指定的文件。
C:\Data\Install\$文件名
系统错误:
系统找不到指定的文件。
希望您能在这种情况下帮助我!其余命令运行正常。
谢谢!
【问题讨论】:
标签: powershell jenkins jenkins-pipeline