Using Octopus.Client to Create Release without a Package

Hi Octopus team,

I am trying to create a release for a project (no nuget package). but I have encountering an issue “Index was outside the bounds of the array”.
It seems like I have to have a nuget package in order to create release using octopus.client?

Below are my powershell script:

$process = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
$channel = $repository.Channels.FindByName($project,“Default”)
$template = $repository.DeploymentProcesses.GetTemplate($process,$channel)

$release = new-object Octopus.Client.Model.ReleaseResource
$release.Version = $template.NextVersionIncrement
$release.ProjectId = $project.Id

$repository.Releases.Create($release)

Thanks

Hi,

Thanks for reaching out.

This script without the lines marked should work: https://github.com/OctopusDeploy/OctopusDeploy-Api/blob/master/Octopus.Client/PowerShell/Releases/CreateRelease.ps1#L22-L28

Hope that helps,
Dalmiro

Hi Dalmiro,

Wow, first time getting reply this fast, I thought you guys are still sleeping.

I was creating the script based on the link you provided, but also I did not include the marked one, but the issue still there.

Thanks.

Hi,

Sorry that snippet didn’t help :(. Could you tell me:

  • Which version of the Octopus.Client you are using
  • Which version of the Octopus Server are you running?
  • Could you send me the exact snippet you were using after I showed you the script in my previous message?

Thanks!
Dalmiro

Hi,

Thanks for getting back.

  • Octopus version 3.12.8
  • Octopus.Client file version 4.13.13.0

Add-Type -Path ‘C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll’

#create a connection to the Octopus Server using API-key
$octopusURI = “my octopus server url”
$apiKey = ‘my API key’
$endpoint = new-object Octopus.Client.OctopusServerEndpoint $octopusURI, $apiKey

#use the connection to access the Octopus Server repository
$repository = new-object Octopus.Client.OctopusRepository $endpoint

$clrProjectId = ‘Projects-141’ #CLR deployment

$project = $repository.Projects.Get($clrProjectId)

$process = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
$channel = $repository.Channels.FindByName($project,“Default”)
$template = $repository.DeploymentProcesses.GetTemplate($process,$channel)

$release = new-object Octopus.Client.Model.ReleaseResource
$release.Version = $template.NextVersionIncrement
$release.ProjectId = $project.Id

$repository.Releases.Create($release)

Hmm that script seems to be working just fine for me.

Thanks,
Dalmiro

Hi,

It works after using Octo.exe, it is just weird that using Octopus.Client is not working.

I have the feeling that this isn’t working because that version of the Octopus.Client and the Octopus Server are not compatible. I’d try with version 3.12.0 of the Octopus.Client: https://www.nuget.org/packages/Octopus.Client/4.12.0

Or even better, if you can upgrade your Octopus Server to the latest and keep using the Octopus.Client you are currently on.

Thanks Dalmiro, that could be the reason. I will stick with octo.exe for now.
Again, thanks for your help.