I am scripting a process to move all the packages that were deployed in a release to a archive folder. To get all the packages for the project i am trying to use
Thanks for getting in touch! OctoPosh unfortunately won’t be of any help in achieving this. I think the easiest way would be to take advantage of some built-in system variables where you can retrieve the path and package id and version. Maybe Octopus.Tentacle.CurrentDeployment.PackageFilePath (which will return something like C:\Octopus\Tentacle\Packages\OctoFx.1.2.3.nupkg) would contain the value needed. You can refer to the following documentation page for additional information and a list of all system variables available.
Using these values, you can then use a PowerShell script to move them however you need to. Would this help meet your requirements? Let me know what you think and if you have any further questions going forward.
So i have created PS script that i am executing as part of a octopus project on the deployment target.
I think i am not getting any value for OctopusPackagePath as I get Path is null error when this script is executed. I was hoping OctopusPackagePath would have folder reference to C:\Octopus\Files which has all the packages
Thanks for following up! This variable evaluates to a single file (the package which is deployed to C:\Octopus\Files in this specific deployment). It’s not returning a directory which is why the message says the path is null. You could try moving the package itself using this variable, or if you want to copy the entire directory I’ve had success with your script by changing the $OctopusPackagePath variable to equal “C:\Octopus\Files”.
I hope this helps get you going! Let me know if you have any further questions going forward.