Octopus.Release.Package works in release notes but not in Variables

Final goal - get hash of last commit from metadata for a package, which then will be used to create a tag after deploy.

Questions:
How I can get last commit in script?
How I can use #{Octopus.Release.Package} in powershell script?
Where this strange value “Releases-10312” came from?

While trying to achieve it, metadata from teamcity is published and successfully worked for Release Notes generation, e.g. like setting Release Notes template like
#{each package in Octopus.Release.Package}
[#{package.PackageId}]
#{each commit in package.Commits}
#{commit.CommitId}
#{/each}
#{/each}

But usage of #{Octopus.Release.Package} in variable doesn’t work, i’m using powershell and https://octopus.com/docs/deployment-process/variables/system-variables.
#{Octopus.Release.Notes} work fine, i’ve use them as a proof that variable substitution and passing it to PowerShell works.

//variables in octopus UI
OctopusReleasePackage #{Octopus.Release.Package}
OctopusReleaseNotes #{Octopus.Release.Notes}
OctopusReleaseId #{each package in Octopus.Release.Package} #{package.PackageId} #{/each}

//powershell
Write-Host $OctopusReleasePackage gives “#{Octopus.Release.Package}”
Write-Host $OctopusReleaseNotes gives actual release notes for this packages
Write-Host $OctopusReleaseId gives Releases-10312

Octopus is 2019.5.8 if it matters, but Release Notes Creation Appears to not be working is avoided by not using variable in teamcity. Octopus upgrade is planned but will be not done for weeks maybe.

Hi Danila,

Thanks for getting in touch! Sorry to hear about this unexpected behavior here. The Releases-10312 value is very strange there. The thread you linked to is related to the following GitHub issue with binding package IDs to a variable in Octopus.

This was fixed in 2019.5.9 (only one patch release ahead of your current version!). Is this the issue you were referring to that you’re hitting?

If not, would you be willing to send me a copy of your verbose task log with debugging variables enabled? This will give us lots more context to help troubleshoot with. The following doc page outlines the process to produce and export this log.

I look forward to hearing back!

Best regards,

Kenny

Hi Danila,

If any information you send us is considered sensitive, you can mark this thread as private or email us directly at support@octopus.com :slight_smile:

Best regards,

Kenny

Sent via email, thanks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.