Get nuget pakcages from list-latestdeployments


I’m working on creating a PowerShell script that will download all the latest NuGet packages used in an environment.

Using the Octo.exe CLI, I’m using:

$deploymentList = octo list-latestdeployments --evironment=Production `
   --outputFormat=json |  ConvertFrom-Json

The problem I’m having is that this returns a semi-colon delimited field named PackageVersions, but these values do not match the NuGet package names:

    "Project": {
      "Id": "Projects-12",
      "Name": "Internal Service"
    "Environment": {
      "Id": "Environments-123",
      "Name": "Production"
    "Tenant": null,
    "Channel": {
      "Id": "Channels-565",
      "Name": "Release"
    "Date": "2021-01-13T13:46:17.513-08:00",
    "Duration": "17 minutes",
    "State": "Success",
    "Version": "1.52.31",
    "Assembled": "2021-01-11T09:34:45.050-08:00",
    "PackageVersion": "Deploy Database Package 23.0.21; Database Script 1.3.42; Database Publish 1.3.42; Deploy Interanl Service 1.3.42",
    "ReleaseNotes": ""

Is there anything in the API or with the CLI that I could use to trace back to the NuGet packages from the latest deployments?

Thank you,

Hi Fausto,

Thanks for reaching out, it seems like this was an oversight on our part!

It looks like only the name of the step which deployed the package is being shown, and not the package’s name. This is likely left over from before Steps could deploy multiple packages.

I’ve raised a Github issue for tracking the progress of getting this command updated to include the package name here. In the meantime I’ll look into a solution which doesn’t use this command.

Feel free to let me know if you have any questions!

Best Regards,

1 Like

Great, thank you for creating the bug. I will follow progress on it.

While the bug is worked on, do you know of away to use the Octo API to get most recent deployed NuGet packages for Production?

Hi Fausto,

I’ve been working on a very rough script for retrieving the package names and versions from the recent deployments for a specific environment, leveraging the Octopus Client. It’s not very elegant or pretty but it gets the package name and version, along with the name of the project that deployed it for a specified environment.

I’ve attached the script below, if you have any questions about executing it or run into any issues please let me know. If it’s not quite what you are after, let me know what you’d like different and I’ll see about modifying for your needs!

Best Regards,

get-latest-deployment-package-names.ps1 (1.2 KB)

This is great! I’ve been working on something similar using the API. First I call the dashboard controller to get the deployments for an environment, I loop through that, then loop through the changes of each one to get the package and version number, then use that to download the raw data. I have attached the script in case you want to take a look, but I will be using yours. Mine is way rougher haha.

get packages for latest deployments.ps1 (1.1 KB)

Hi Fausto,

Glad to hear it’ll be useful, thanks for sharing your script too! I always enjoy seeing other approaches and Powershell tricks to ‘borrow’!

Unfortunately I couldn’t see an easier way to retrieve the package name other than via the deployment process for the recent releases, and hate that there is a nested loop in the script. I’ll keep playing around with it and hopefully get an example added to the docs, however once the issue I created here is resolved then this should be much easier to retrieve!

Feel free to reach out if you have issues or questions in future!

Best Regards,

1 Like