【问题标题】:Failed to create Release artifact directory error after cancelling Release and starting new one取消发布并开始新的发布后,无法创建发布工件目录错误
【发布时间】:2020-12-21 22:27:54
【问题描述】:

这似乎只有在我取消发布部署然后开始新部署时才会发生。它迫使我进入代理并手动重新启动它们。

实际的错误是..

“无法创建发布工件目录'C:\agent_work\r3\a'。---> System.IO.IOException: 进程无法访问文件'\?\C:\agent_work\r3\a'因为它正被另一个进程使用。”

在取消发布后创建新版本时,TFS 中是否有办法清除这些潜在问题?如果我让它完全正常运行,新版本运行良好没有问题。这只发生在我取消并尝试开始新的时候。

【问题讨论】:

  • 发布管道中有哪些任务?看起来发布管道任务启动的某些进程未正确关闭,并且在您取消发布时仍在使用发布工件目录。

标签: tfs azure-pipelines-release-pipeline


【解决方案1】:

您可以使用handle 之类的实用程序编写一个脚本来释放锁定的文件或文件夹。

例如:

$pathToRelease = $env:System.DefaultWorkingDirectory
Write-Host "$PathToRelease is locked! trying to kill the process..."
$processes = path\to\handle64.exe -nobanner -accepteula $PathToRelease

# Remove empty lines
$processes = $processes | Where-Object {$_ -ne ""}
Write-Host $processes.ForEach({ Write-Host $_ })

if($processes -notmatch "No matching handles found.")
{
   foreach($process in $processes)
   {
       # Some excluded processes, you can decide what which you want
       if($process -match "explorer.exe" -or $process -match "powershell.exe"
       {
                continue
       }
       $pidNumber = $process.Substring(($process.IndexOf("pid") + 5),6)
       $isProcessStillAlive = Get-Process | Where-Object {$_.id -eq $pidNumber}
       if($Null -ne $isProcessStillAlive)
       {
           Stop-Process -Id $pidNumber -Force
           Start-Sleep -Seconds 1
       }
   }
}
else
{
   exit 0
}

配置脚本以在发布被取消的情况下运行。

【讨论】:

    猜你喜欢
    • 2018-10-18
    • 1970-01-01
    • 2020-03-26
    • 1970-01-01
    • 2019-05-04
    • 1970-01-01
    • 2021-11-18
    • 2016-07-23
    • 1970-01-01
    相关资源
    最近更新 更多