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}
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.
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?
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.
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?
Also the variable Octopus.Tentacle.CurrentDeployment.PackageFilePath seems not working!! Tried Write-host “Package File Path: #{Octopus.Tentacle.CurrentDeployment.PackageFilePath}” but it returns nothing.
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.