Get packages for a release via API

Hi, i have a edge case situation where i need to access packages deployed on a release for a given project via the Octopus API. Has anyone manged to do this?

Hi,

Thanks for getting in touch! I’m sorry for the delay in getting back here. I may need some further information to better help you here.

When you say you need to access the packages, do you need to download them or just see what package was used?

I do not believe you can directly download the packages by using the API but you should be able to find out what version of the package was used for each step in the release.

If you could provide some further information about your requirements here I will hopefully be able to provide a more detailed answer. :slight_smile:

Looking forward to hearing from you.

Best regards,

Hi Daniel

Thanks for the response. I managed to get it sorted by using a cmdlet from the Octoposh library basically for reference we did it like this, it seems a bit ‘round the houses’ but if Octopus thought that a package had already been deployed we could not access the package name in the Octopus.Action (perhaps a bug?):-

Import-Module Octoposh
Set-OctopusConnectionInfo -Server $($OctopusParameters[‘Octopus.Web.BaseUrl’]) -ApiKey $OctopusAPIKey | Out-Null
$release = Get-OctopusRelease -ProjectName $OctopusParameters[“Octopus.Project.Name”] -ReleaseVersion $OctopusParameters[“Octopus.Release.Number”]

[System.Collections.ArrayList]$packages=$release.Packages
$distinctpackages = @()

foreach ($package in $packages)
{
$fullpackagename = $($package.Id) + “.” + $($package.Version) + “.nupkg”

if ($distinctpackages -notcontains $fullpackagename)
{
	$distinctpackages += $fullpackagename
}

}

$fileListToSend = $distinctpackages -join “,”

Set-OctopusVariable -name “FileListToSend” -value $fileListToSend