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
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: