Я вижу ниже журналы ошибок, когда когда-либо пытаюсь скопировать элементы из пути в пункт назначения. Задача PS-скрипта запланирована под Jenkins Job. Это бесполезно, поскольку сборка сбоев происходит каждый раз.Copy-Item: процесс не может получить доступ к файлу Power-Shell
Ошибка ЖУРНАЛЫ РЕГИСТРАЦИИ-
Copy-Item : The process cannot access the file
'\\10.0.1.190\d$\Build\RPC\Fortius.RPC.AmadeusAir\Common.Logging.Core.dll' because it is being used by another process.
At C:\Users\Administrator\AppData\Local\Temp\hudson5254771699639808940.ps1:33 char:1
+ Copy-Item "$ReleaseDir\*" $AmadeusDir -Force -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
PS Script-
# force strict - so any variable used before being assigned causes an error
Set-PsDebug -Strict
# force PowerShell to exit with a non-zero code on the first error
$ErrorActionPreference = 'Stop'
# set directories here once, so we can reuse
$AmadeusDir = "\\$env:SERVER\d$\Build\RPC\Fortius.RPC.AmadeusAir"
$ReleaseDir = "C:\Amadeus\BTP\src\Fortius.Amadeus.Air.RPC.Host\bin\Release"
# get directory contents (are you expecting these to return to Jenkins?)
Get-ChildItem "$AmadeusDir\*"
Get-ChildItem "$ReleaseDir\*"
# create the search directory if it doesn't exist
if (-not (Test-Path -Path $AmadeusDir -PathType Container)) { New-Item -Path $AmadeusDir -type directory -Force }
# get the service, but fail gracefully if it doesn't exist
$service = Get-Service -Name AmadeusAirWindowsService -Computername $env:SERVER -ErrorAction SilentlyContinue
# if we have a service, stop and delete it
if($service.Status)
{
sc.exe \\$env:SERVER stop AmadeusAirWindowsService
if ($LASTEXITCODE -ne 0) { throw "error stopping the service: $LASTEXITCODE" }
Write-Host "AmadeusAirWindowsService STOPPED"
sc.exe \\$env:SERVER delete AmadeusAirWindowsService
if ($LASTEXITCODE -ne 0) { throw "error deleting the service: $LASTEXITCODE" }
Write-Host "AmadeusAirWindowsService DELETED"
}
# copy release to search
Copy-Item "$ReleaseDir\*" $AmadeusDir -Force -Recurse
# (re)create the service
sc.exe \\$env:SERVER create AmadeusAirWindowsService start=auto DisplayName="Fortius Amadeus Air RPC Service" binPath= D:\Build\RPC\Fortius.RPC.AmadeusAir\WorldVentures.Fortius.Amadeus.Air.RPC.Host.exe
if ($LASTEXITCODE -ne 0) { throw "error creating the service: $LASTEXITCODE" }
sc.exe \\$env:SERVER description AmadeusAirWindowsService "This service hosts Fortius Amadeus Air RPC service"
if ($LASTEXITCODE -ne 0) { throw "error adding description to service: $LASTEXITCODE" }
sc.exe \\$env:SERVER start AmadeusAirWindowsService
if ($LASTEXITCODE -ne 0) { throw "error starting the service: $LASTEXITCODE" }
Write-Host "AmadeusAirWindowsService STARTED"
В качестве альтернативы я использую xcopy "From" "destination" /k/e/d/Y
сделать это