Octopus REST API - Get packages used in a release given a projectId

Hey Octoguys!
We’re trying to implement an automated reporting system within our CD to populate some pages internally. One of the requirements is after a release to fill in a table in Confluence with the contents of said release, and links to the download pages.

I’m able to get the ProjectId given the name of the project, and grab the release that had just occurred programmatically through Bamboo, however the json object doesn’t seem to include packages, just step names and their associated version.

What’s the best way to get the packageId if it isn’t provided in the release?

Hi,

Thanks for reaching out! Once you get the release object/json, It’ll have a collection of Links on on it one of them will be called ProjectDeploymentProcessSnapshot:

{
  "Id": "Releases-4870",
  "Assembled": "2017-03-13T16:35:20.007+00:00",
  "ReleaseNotes": null,
  "ProjectId": "Projects-322",
  "ChannelId": "Channels-382",
  "ProjectVariableSetSnapshotId": "variableset-Projects-322-s-4-2NLHC",
  "LibraryVariableSetSnapshotIds": [],
  "ProjectDeploymentProcessSnapshotId": "deploymentprocess-Projects-322-s-123-WUR89",
  "SelectedPackages": [
    {
      "StepName": "Deploy",
      "Version": "1.0.15.0"
    }
  ],
  "Version": "1.0.15.0",
  "Links": {
    "Self": "/api/releases/Releases-4870{?force}",
    "Project": "/api/projects/Projects-322",
    "Progression": "/api/releases/Releases-4870/progression",
    "Deployments": "/api/releases/Releases-4870/deployments{?skip}",
    "DeploymentTemplate": "/api/releases/Releases-4870/deployments/template",
    "Artifacts": "/api/artifacts?regarding=Releases-4870",
    "ProjectVariableSnapshot": "/api/variables/variableset-Projects-322-s-4-2NLHC",
    "ProjectDeploymentProcessSnapshot": "/api/deploymentprocesses/deploymentprocess-Projects-322-s-123-WUR89",
    "Web": "/app#/releases/Releases-4870",
    "SnapshotVariables": "/api/releases/Releases-4870/snapshot-variables",
    "Defects": "/api/releases/Releases-4870/defects",
    "ReportDefect": "/api/releases/Releases-4870/defects",
    "ResolveDefect": "/api/releases/Releases-4870/defects/resolve"
  }
}

Once you GET the deployment process snapshot, you’ll see each step along with the pacakge ID declared on it. There you’ll need to map the info for each step with the SelectedPackages property of the initial release object.

If you are using Powershell you might wanna give Octoposh a try, as it has a cmdlet called Get-OctopusRelease that returns the package info for each release as shown on the attached screenshot.

Or you can also check what Octoposh does to populate the packages in the code: https://github.com/Dalmirog/OctoPosh/commit/6efd149a0479fe6c30bffc3f25a68d544a5721ec

Hope that helps!
Dalmiro