Obtaining path to package deployments on Tentacle

Once I have deployed a package to a tentacle, it is placed in a directory like C:\Octopus\Applications<Environment Id><Package Id><Version>. This is great, exactly what I want. Next, I have another service that will run on that machine which will need to find a package deployed to that Tentacle given some version spec.

So, a few questions:

  • From an application running on a Tentacle, how can I discover that the machine is a Tentacle and get more information about that? Is it possible to discover the current machine’s Machine Id so that I can ping the central Octopus API about it?
  • Once I have established that I am running on a Tentacle, how can I iterate packages for a particular environment and find a deployed version of a package that matches a certain version spec? Is there a facility for finding, say, version 4.* of a package? If not, can I at least get a list of all versions currently deployed to that machine?

For both these questions, most times my app is in .NET so if there is a series of API calls I can make, great! I definitely want to avoid trying to parse tentacle.config or dig in the Windows registry for the path to the installation (though the latter may be the easiest way to get at it). How would I best get at this information if I were running from, say, perl, or a bash script?

Hi,

Thanks for reaching out! Let me give you a hand with those questions:

From an application running on a Tentacle, how can I discover that the machine is a Tentacle and get more information about that? Is it possible to discover the current machine’s Machine Id so that I can ping the central Octopus API about it?

If you are going to have another service running on that machine, there’s no point really in consulting another server for something you could figure out from a local perspective. If you check the registry and there’s a child node in HKEY_LOCAL_MACHINE\SOFTWARE\Octopus\Tentacle, then the machine is a Tentacle.

Once I have established that I am running on a Tentacle, how can I iterate packages for a particular environment and find a deployed version of a package that matches a certain version spec? Is there a facility for finding, say, version 4. of a package? If not, can I at least get a list of all versions currently deployed to that machine?*

Once you are in HKEY_LOCAL_MACHINE\SOFTWARE\Octopus\Tentacle\[Instance Name], do the following:

  1. Grab the value of the key ConfigurationFilePath which should hold a value similar to C:\Octopus\Tentacle.config
  2. In the same folder as that C:\Octopus\Tentacle.config file, there will be another file called DeploymentJournal.xml with a structure similar to this:
<Deployments>
<Deployment WasSuccessful="True" CustomInstallationDirectory="C:\Octopus\Applications\Dev\Testapp\1.0.15_3" RetentionPolicySet="Environments-1/Projects-1022/Step-Deploy package/Machines-601/<default>" ExtractedTo="C:\Octopus\Applications\Dev\Testapp\1.0.15_3" ExtractedFrom="C:\Octopus\Files\Testapp.1.0.15.nupkg-d67c4556-7ab1-42fc-b9dc-c710c7cd6a9c" InstalledOn="2017-02-23 19:28:28" PackageVersion="1.0.15" PackageId="Testapp" ProjectId="Projects-1022" TenantId="" EnvironmentId="Environments-1" Id="9f4c3b60-e512-4d29-8435-e0d1c438b07d"/>
</Deployments>

The Octopus Server doesn’t really hold the paths where things were deployed in Tentacles. When it needs to figure that out (for retention policies for example), it consults this DeploymentJournal.xml in each Tentacle. If you convert that XML into a .NET object, it should be fairly simple to LINQ your way through the combination of Release Numer/Package version you are looking for.

Hope that helps!
Dalmiro

Thank you for the quick and thorough response. I had hoped you already had an API for grepping the info above, but just having confidence that I won’t be wasting time by building one for myself is quite fine. Cheers!