How to get the package in a server-side script?

I want to create a custom powershell step that copies the release package to azure storage. I was going to set this up to run on the Octopus Server. How do I get the release package?

Thanks,
Tom

Hi Tom,

Thanks for reaching out! Just to make sure we are on the same page: You want to upload the unextracted nuget/zip package that was deployed on another step to Azure Storage?

Dalmiro

No. I have two environments: QA and DemoKit. The project has 2 process steps. The 1st step does a “normal” deployment to the QA environment where the nuget package is copied to the machines in the QA environment, and extracted and installed on each machine. The 1st step is configured to only run when the target is the QA environment. The 2nd step will be configured to only run when the target is the DemoKit environment. All I want it to do is run a powershell script on the Octopus server to copy the kit to an Azure blob store. (The intention is that after the kit is tested on the QA machines, it can be promoted to the DemoKit repository.) I can get the powershell running on the server to access the azure blob, but I don’t know how to get it to find the nuget package I need to copy.

Hi Tom,

Thanks for taking the time to explain your setup in more detail. There’s a couple of ways you can do this, depending on where your package is sitting in the first place:

in both cases you will be getting the package from the repository and not from a machine where you previously deployed it

If you are using the Octopus Built-In repository

If you are using this repository to host your package, this means the package is in a physical folder on the Octopus server (by default under c:\Octopus\packages[package id]). With that in mind, all you’ll need would be to have a Powershell script step that runs on the Octopus Server that looks for that package version and pushes it to Azure.

If you are not using the Octopus built-in repository

If you are using an external repository, then the only way to get a package anywhere is through a Tentacle. You could install a Tentacle on the same VM where you are running the Octopus server, register it on your DemoKit environment, and then have a regular Package Deploy step that deploys your package somewhere(*) and then pushes it to Azure.

(*) There’s a gotcha on this part: There’s currently no way to avoid having Octopus extract the contents of the package during the deployment. So you’ll have to use an Octopus variable to get the un-extracted package from disk. I sort of solved that part for you with this script that you should put on the Post-Deploy Script field of your Package Deploy Step: https://gist.github.com/Dalmirog/4aa9eaed3e1a6a3ebe86d087068e8fcb

On line 18 you should be putting your logic to upload the package to azure.

There also a uservoice suggestion to add a switch to tell Octopus not to extract the package. I’ll appreciate if you take a few seconds to add some votes to it, as It’ll help other users that run into the same scenario as you: https://octopusdeploy.uservoice.com/forums/170787-general/suggestions/13805631-option-to-not-extract-packages

Let me know if you have any questions about this.

Cheers,
Dalmiro