Deploying package reference to Windows folder location

Hi

I’m trying to use a PS script to copy a octopus package from octopus dir to another folder location.

The below script only seems to be copying a empty folder and not the artefact inside zip file.

Can I please be advised what I’m doing wrong?

$adbsPath = $OctopusParameters[“Octopus.Action.Package[RetentionCampaignDecisionService].ExtractedPath”]
$dstPath = “C:\RetentionCampaign\deployment\repository\archive”

Copy-Item -Path $adbsPath -Destination $dstpath

this is the package reference I’m to extract artefact inside then to copy destination

it only seems to be copying an empty folder and not the artefact inside the zip folder
image

Hi @tabrahams1,

Thanks for reaching out! It looks like you’re missing a -Recurse switch on the Copy-Item command.

Additionally, you may want a -Force on there as well, otherwise, additional runs will fail if items already exist in that folder. Unless they always vary or you are cleaning up that folder. So the full command would look like: Copy-Item -Path $adbsPath -Destination $dstpath -Recurse -Force

I’m not familiar with your process or what your goals are, but you may want to look into Retention policies - Octopus Deploy as they might accomplish what you are trying to do here. As your script is currently, you will only ever have the latest version of the package that was extracted unless you add in another variable to hold different versions. Then you will also have to worry about cleanup whenever the time may come.

Let us know if we can be of further assistance! Happy deployments!

Thank you @mark.reeder

Worked like a charm :ok_hand: