Powershell 脚本在 Octopus 中失败

Powershell script failing in Octopus

我的章鱼进程中有一个 powershell 脚本 运行 服务器上的 powershell 脚本。当我 运行 服务器本身上的脚本时,它 运行 没问题。当我尝试将脚本合并到章鱼部署过程中时,它只是挂起而不是 运行。它到达第 8 行并挂起。

第 8 行是否有我没有看到的内容。以 $process

开头的行
Write-Host "Executing Protractor cmdline: & "$TestProtractorPathAndName" 
$TestProtractorArgs "
if (test-path $TestProtractorResultPath) {Remove-Item –path 
"$TestProtractorResultPath" –recurse}
New-Item -ItemType "directory" -path "$TestProtractorResultPath"
$args = "$TestProtractorArgs" 
Write-Host "Run Protractor scripts"
Write-Host $TestProtractorResultFile
Write-Host $TestProtractorResultFileLabel
$process = Start-Process "$TestProtractorPathAndName" $args -Wait - 
PassThru
Write-Host 'Exit code = $($process.ExitCode)'
New-OctopusArtifact -Path "$TestProtractorResultFile" -Name 
"$TestProtractorResultFileLabel"
if ($process.ExitCode -eq 0){
  Write-Host "Protractor cmdline complete"
} else {
  Write-Error "Protractor cmdline failed"
}

问题可能是权限问题 - 可以在机器上亲自 运行 脚本的交互式帐户与安装并 运行ning 的触手之间的权限差异机器上的服务。

解决这些问题的最佳方法是将您的脚本模拟 运行 为触手。这可以在 Octopus Deploy 中使用 Script Console 功能轻松实现。

在这里您可以编写您的 PowerShell 脚本并在触手上执行它,而不是 运行在部署目标上使用交互式会话来执行它 - 它会在您尝试解决问题时提供更清晰的画面像这样。

希望对您有所帮助