How to print Octopus package name with the extension of a particular step

(Eshwar Balakrishna) #1

I am trying to look for a Octopus variable that helps me print Octopus package name with extension referred in a step. Also can the periods be replaced with any other symbols, can you also help me with this.

Currently using the below variable to print something like PackageName_3.42.28072-28, but I am looking for something like PackageName_3_42_28072.zip.

Write-Host "Package Name: #{Octopus.Action[Deploy UI to Staging Folders].Package.NuGetPackageId}_#{Octopus.Action[Deploy UI to Staging Folders].Package.NuGetPackageId}

Any help would be really helpful.

Thanks,
Eshwar Balakrishna

(Justin Walsh) #3

Hi @eshwarbabub!

The closest variable we have to what you are seeking is Octopus.Tentacle.CurrentDeployment.PackageFilePath, which will return the full path and filename of the package being deployed. You may need to split() it to get just the file name, but that is trivial.

A handy list of all of our system variables can be found in our documentation at https://octopus.com/docs/deployment-process/variables/system-variables

I hope this helps!

(Eshwar Balakrishna) #4

Hi Justin,

Thanks for the response.

Meanwhile, I work on the above steps. Can you also help me if there is a way to download the project package manually with a step and place it in a Folder location using PowerShell?

(Justin Walsh) #5

The easiest way of doing that particular process would be to make use of the “Transfer a Package” step template to transfer the package to the target. You can specify the transfer path to dictate the final destination of the package file, eliminating the need to script it.

Happy Deployments!

(Eshwar Balakrishna) #6

Transfer package step worked but has a different name when compared to the library. Something like @S4.01.27727@4499905C20C7CB4C81F10577C19DF51E.zip but the name in the library is .4.01.27727.zip . Do we have any other way to retain its name?

(Eshwar Balakrishna) #7

Also the variable Octopus.Tentacle.CurrentDeployment.PackageFilePath seems not working!! Tried Write-host “Package File Path: #{Octopus.Tentacle.CurrentDeployment.PackageFilePath}” but it returns nothing.

(Justin Walsh) #8

Hi again @eshwarbabub!

Octopus.Tentacle.CurrentDeployment.PackageFilePath is only scoped in the deploy step - if you would like to use it outside the deploy step, you would want to do something like:

In your deployment step (Deploy to IIS etc.):

  • Add the “Custom Deployment Script” feature (under configure features).
  • In one of the scripts, add:
    Set-OctopusVariable -name "PackageFilename" -value $OctopusParameters["Octopus.Tentacle.CurrentDeployment.PackageFilePath"]

In later steps, such as a “Run a script” step, you should be able to access the variable
Octopus.Action[<your_deploy_step>].Output.PackageFilename

As for the “Transfer a Package” step, we corrected a bug in version 3.7.15 that was causing the transferred package to use the “staging” file name (as you’re seeing), rather than the package name. If you update to a later version, you should just see YourWebApp.4.01.27727.zip in the destination directory.

I hope this helps!

(system) closed #9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.