在Octopus Deploy中运行powershell脚本,请参考包中的exe

时间:2018-02-01 10:33:09

标签: powershell octopus-deploy

部署后,我希望在接收触手时执行脚本,引用包中的exe。

        Write-Host ("Initial path " + (Get-Location).Path)
    Write-Host ("Will run in " + $Octopus.Tentacle.CurrentDeployment.PackageFilePath)
    Set-Location $Octopus.Tentacle.CurrentDeployment.PackageFilePath

    Write-Host ("Running PingConfigurator")

    $CMD = ".\Tdc.PingConfigurator.App.exe"
    $arg1 = "-e AndersPing9"

    & $CMD $arg1

    Write-host("Migration PingConfigurator")

但是,我在powershell中遇到一个例外,说

Substituting variables in: F:\Octopus\Work\20180201102638-23-33\PostDeploy.ps1 
February 1st 2018 11:26:43Info
Initial path F:\Octopus\Work\20180201102638-23-33 
February 1st 2018 11:26:43Info
Will run in  
February 1st 2018 11:26:43Error
Set-Location : Cannot process argument because the value of argument "path" is  
February 1st 2018 11:26:43Error
null. Change the value of argument "path" to a non-null value. 
February 1st 2018 11:26:43Error
At F:\Octopus\Work\20180201102638-23-33\PostDeploy.ps1:3 char:1 
February 1st 2018 11:26:43Error

我们在谈论什么样的“道路”?我该怎么办才能补救?

谢谢,安德斯

1 个答案:

答案 0 :(得分:1)

以下是我之前的表现:

[string]$nuGetDeployStepName = "that step there"
[string]$workingDirectory = $OctopusParameters["Octopus.Action[$nuGetDeployStepName].Output.Package.InstallationDirectoryPath"]

这将返回解压缩NuGet文件的文件夹。