我的Jenkins工作低于活动。
以下是我的PowerShell脚本:
Get-ChildItem "C:\Location\*"
$service = Get-Service -Name value -Computername $env:SERVER -ErrorAction SilentlyContinue
sc.exe \\$env:SERVER stop value
Write-Host "value STOPPED"
sc.exe \\$env:SERVER delete val
Write-Host "val DELETED"
Copy-Item "C:\Location\*" "\\$env:SERVER\d$\Location" -Force -Recurse
sc.exe \\$env:SERVER create val start=auto DisplayName ="val" binPath= D:\Location.exe
sc.exe \\$env:SERVER description value"value"
sc.exe \\$env:SERVER start value
Write-Host "value STARTED"
if ($error) { exit 1 }
错误日志:
Copy-Item : The process cannot access the file '\\Location' because it is being used by another process. At C:\Users\Administrator\AppData\Local\Temp\hudson2059984936352103941.ps1:18 char:5 + Copy-Item "C:\Location\*" " ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Copy-Item], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand [SC] CreateService FAILED 1072: The specified service has been marked for deletion. [SC] ChangeServiceConfig2 FAILED 1072: The specified service has been marked for deletion. [SC] StartService FAILED 1058: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
你可以帮我解决这个错误吗?我是否需要重新启动部署服务器以便我的进程被杀死?如果是这样,我觉得这不相关,也不能在prod服务器上做。
答案 0 :(得分:0)
问题是你有另一个使用dll的进程。由于它正在使用,你无法删除它。在删除之前,您需要确保没有进程正在使用您的dll。要实现这一目标,您需要找出正在使用它的进程,为什么要使用它并确保它将被关闭。如果下次也出现问题,那么您需要将该过程关闭到脚本中。