Delete nupkg during PostDeploy.ps1

As part of our deployment, we’d like to delete the nupkg from the tentacle’s packages folder.

The cleanup feature has been suggested and is on trello (ref http://help.octopusdeploy.com/discussions/suggestions/64-ability-to-configure-tentacle-cleanup ), but we would like something for the interim.

Our approach is to invoke in our PostDeploy.ps1 a Remove-Item of the nupkg in \Octopus\Tentacle\Packages. In general, this has worked for us, across multiple deployments and multiple tentacles.
Across all of these runs, there is one tentacle on which the deployment has regularly failed. The failure always occurs at Stage 3 : Installation. Our debugging on this particular tentacle suggests that our Remove-item defined in our PostDeploy.ps1 is executed before any logic in our PreDeploy.ps1 or Deploy.ps1.

This is the typical error we see:

2012-04-18 15:57:33 DEBUG Begin deployment of package: EnvironmentSpecificConfig.1.0.652.725
2012-04-18 15:57:33 DEBUG Tentacle Agent info below
2012-04-18 15:57:33 DEBUG - Machine name: TEWEB04
2012-04-18 15:57:33 DEBUG - Is 64 Bit: True
2012-04-18 15:57:33 DEBUG - Service user name: SYSTEM
2012-04-18 15:57:33 DEBUG - CLR Version: 4.0.30319.261
2012-04-18 15:57:33 DEBUG - Current directory: C:\Windows\system32
2012-04-18 15:57:33 DEBUG - OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
2012-04-18 15:57:33 DEBUG - Tentacle Version: 0.9.620.4
2012-04-18 15:57:33 INFO Package will be extracted to: E:\Octopus\Tentacle\Applications
2012-04-18 15:57:33 DEBUG The package ‘EnvironmentSpecificConfig’ was already extracted on this Tentacle previously - it will be uninstalled before proceeding.
2012-04-18 15:57:33 DEBUG Installing package ‘EnvironmentSpecificConfig.1.0.652.725’ from uploaded package cache via NuGet into E:\Octopus\Tentacle\Applications
2012-04-18 15:57:33 ERROR Error while executing job: Unable to find version ‘1.0.652.725’ of package ‘EnvironmentSpecificConfig’.
System.InvalidOperationException: Unable to find version ‘1.0.652.725’ of package ‘EnvironmentSpecificConfig’.

Does anyone have insight on why we’re seeing this behavior on this particular tentacle?
We’d like to know if we’ve misunderstood octopus or powershell.

Thanks.
Lisa

Hi Lisa,

If you look under E:\Octopus\Tentacle\Packages on the rogue tentacle, can you see EnvironmentSpecificConfig.1.0.652.725.nupkg? The PostDeploy.ps1 shouldn’t be executed first.

My guess is it got deleted once, and since then it has never been uploaded again (if the package is already installed Octopus may skip uploading it)

Paul

Hi Paul,

Genius insight. Thanks for solving my confusion.

We’re deploying the nupkg to several servers, distributed over several steps. Turns out the server was mistakenly registered to more than one step.

Thanks for the octopus product, and for the additional support.
Lisa

Glad you got it sorted Lisa, if there’s anything I can do to help or if you have any suggestions on how the product can be improved, please let me know.

Paul