No package version was specified for the step - Create Release through Octopus.Client 4.41.2

(Steven Maglio) #1

Error Message

(From Powershell)

Exception calling "Create" with "2" argument(s): "There was a problem with your request.

 - No package version was specified for the step 'Unzip Package'
"
At D:\Projects\Main\Powershell\Ucsb.Sa.Powershell\OctoUcsb\public\New-OctoReleaseUcsb.ps1:55 char:10
+ ...      return $global:OctoUcsb.OctoClient.Repository.Releases.Create($r ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : OctopusValidationException

Original Error

Expected Behavior

I’m attempting to create a new release for a project using the Octopus.Client.dll from within Powershell. I was expecting for the release to be created without an error.

I’ve also tried this with the latest Octopus.Client.dll (6.2.1) and received the same error message.

Steps

# http://stackoverflow.com/questions/1183183/path-of-currently-executing-powershell-script
$root = Split-Path $MyInvocation.MyCommand.Path -Parent;

# https://www.powershellgallery.com/packages/GenericMethods/1.0.0.1
Import-Module GenericMethods

# bump up TLS to 1.2
[System.Net.ServicePointManager]::SecurityProtocol = 
				[System.Net.SecurityProtocolType]::Tls12 + [System.Net.SecurityProtocolType]::Tls11 + [System.Net.SecurityProtocolType]::Tls;


$resourcesDir = Join-Path $root "Resources"
Add-Type -Path (Join-Path $resourcesDir "Newtonsoft.Json.dll") # 7.0.1
Add-Type -Path (Join-Path $resourcesDir "Octopus.Client.dll") # 4.41.2 or 6.2.1


$global:OctoUcsb = @{
	ApiKey = "your key here"
	Uri = "https://your-instance-here"
}

$global:OctoUcsb.OctoClient = New-Object `
		-TypeName Ucsb.Sa.Enterprise.OctoDeploy.Client.OctoClient `
		-ArgumentList @($global:OctoUcsb.Uri, $global:OctoUcsb.ApiKey)

$projectName = "Ucsb.Sa.Sait.Ops.WebFarmTlsSettings"

$project = $global:OctoUcsb.OctoClient.Repository.Projects.GetAll() | Where-Object { $_.name -like $projectName }

$channelsLink = $project.Links["Channels"].AsString()
$channels = Invoke-GenericMethod	-InputObject $global:OctoUcsb.OctoClient.Repository.Client `
									-MethodName List `
									-GenericType @([Octopus.Client.Model.ChannelResource]) `
									-ArgumentList @($channelsLink, $null)
$channel = $channels.Items |? { $_.Name -eq "Any Environment" }

$release = New-Object Octopus.Client.Model.ReleaseResource
$release.ProjectId = $project.Id
$release.ChannelId = $channel.Id
$release.Version = "2019.4.2.53036"

# this line produces the error
$global:OctoUcsb.OctoClient.Repository.Releases.Create($release, $false)

This image is from the original source code, but the error can be reproduced with the simplified code above:

The package does exist and the version number is the latest version listed in the Library.

A screenshot of the Process definition:

Strangely, a somewhat similar command from octo.exe (6.2.1) is successful:

(Shannon Lewis) #3

Hi Steven,

Thanks for reaching out. This can be a little bit deceptive, octo.exe is actually doing quite a lot behind the scenes when you run that command. The code is public, the command starts here and uses the ReleasePlanBuilder to do the real heavy lifting.

From what I can see in the screenshots, I think the crux of the issue is that the SelectedPackages list in the ReleaseResource you are creating is empty. It should contain an entry per package in your deployment process, where each SelectedPackage contains the action (step) name and the package version. If you’re using the multiple packages on script step then you needs to set PackageReferenceName too, otherwise it can stay blank.

Hope that helps and please let me know how you go and if I can assist further.

Regards
Shannon

(Steven Maglio) #4

That’s most likely it! Thank You!

(I haven’t had a chance to verify the result as we changed directions and setup auto-release creation when the .nupkg is uploaded)

(system) closed #5

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