Anders Juul
Anders Juul

Reputation: 2604

Running powershell script in Octopus Deploy w ref to exe in package

Once deployed, I wish a script to executed on receiving tentacle, referencing the exe in package.

        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")

However, I get an exception in powershell, saying

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

What 'path' are we talking about? What can I do to remedy?

Thanks, Anders

Upvotes: 0

Views: 1045

Answers (1)

gvee
gvee

Reputation: 17161

Here's how I've done this before:

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

This returns the folder in which the NuGet file was unpacked.

Upvotes: 1

Related Questions