VersioningStrategy always empty

Hello
I had a powershell script that i used to add version rules to channels inside projects. This is failing now. I hadn’t run it in a while so i’m suspecting something has changed since we are upgrading regularly. We are currently on version v2021.2

I pinned the issue down to the project’s VersioningStrategy being empty in the project object i’m getting back from the API.
I checked in the GUI and it has a version strategy which is based on a package step.
However it’s always blank when I use the Octopus.Client API inside powershell .

Below is part of my powershell code.
I’m wondering if VersioningStrategy has been moved to some other place?

$projects = $repository.ProjectGroups.GetProjects($projectGroup)
foreach($project in $projects)
{
$project.VersioningStrategy #<—tihs is always empty
}

Any tips would be greatly appreciated.
Thank you
Fabian

Hi Fabian,

Thanks for getting in touch! Great question, and it’s very possible something did change between the last version you ran it successfully and your current version. Depending on the previous working version, we might be able to narrow it down to which change (re: introduction of Spaces, or Config As Code, etc.), if applicable. However I’d like to get a bit more clarity on your process and goal here.

$project.VersioningStrategy looks to map directly to the release versioning on the project itself, not in version rules on channels. In the UI that is here:

But as I understand you’re wanting to add to the channel itself. Unfortunately I don’t see any pre-written sample scripts to do this but I believe you’d need to use the channels API where you’d see something like this that you might be wanting to target:

Another handy thing to keep in mind is that Octopus is API-first, so even checking out the network tab to see the calls made behind the scenes when making your desired change in the web portal might be a lot of help. :slight_smile:

I hope this helps, and please let me know how you go!

Best regards,

Kenny

Hi Kenneth
Thank you for the quick response.
Project.VersioningStrategy used to get me the version strategy for the project which was set up in another place on the UI. I think it has now moved to the Deployment Settings.
I need the versioning strategy of the project not the channel because the channel doesn’t have a versioning rule unless it has rules. I’m trying to add rules.

Here’s more info

Once i found the project i want to change in my ps script i get the channel i’m interested in
$Channel = $repository.Channels.FindByName($project, $ChannelNames[$i])

looking at that channel object there’s no versionin stragegy
image

I’m looping through the rules for the channel and if the one i want to add doesn’t exist i need to build a rule object

$NewRule = New-Object Octopus.Client.Model.ChannelVersionRuleResource
$NewRule.ActionPackages.Add($PackageReferenceStep)
$NewRule.Tag = $VersionRulePreReleaseTags[$i]
$Channel.Rules.Add($NewRule)

That requires an ActionPackage which is the versioning strategy
Used to be this $project.VersioningStrategy.DonorPackage

But as i explained that is now always blank.

Do you know where in the API i can get the versioning strategy now?
Like where are the deployment settings. I couldn’t find them.

Thank you.

Fabian

Hi @fhanggi,

Thank you for getting back to us.

I believe the versioning strategy endpoint you are looking for is:

OCTOPUS_URL/api/Spaces-XXXX/projects/Projects-XXXX/deploymentsettings

See my example below:

You can also test this in Swagger:

If you have any additional questions, please don’t hesitate to ask!

Best Regards,
Donny

I made a mistake. I’m not using the API like you show it. I am using the Octopus.Client.dll in powershell.
There i cannot find the DeploymentSettings.
I’m using the latest version of Octopus.Client from nuget. It’s version 11.6.3644.
When i inspect the project object there is no DeploymentSettings object.
do you know how to get the the DeploymentSettings for a proejct by using Octopus.Client?

Thank you very much
Fabian

Hi Fabian,

Thanks for following up! Firstly, I suspect you’re trying this correctly, and while I was looking through this thread again I had a sneaking suspicion that you may be hitting a known and current bug which I’ll link below. I might be off the mark but it’d be worth ruling out at the very lease.

I’m curious of a few things:

Are you able to successfully browse through the project in the web portal?
Are you seeing this same issue across all of your projects?
If it’s just a subset of projects, is this problematic project(s) cloned from another project (as discussed in more detail in the above linked bug report)?

I look forward to hearing back!

Best regards,

Kenny

Hi Kenny

I just found out how to get it to work. However To answer your questions. Yes i can browse through all my projects . Yes my issue (VersioningStrategy being empty) was for all projects that i looked at in my powershell code.

It seems that VersioningStrategy object for the project is not populated anymore. Not sure if that is a bug or by design.

Here is what i had to do to get the VersioningStrategy for a project

Before (not working)
$project.VersioningStrategy.DonorPackage

After (working)
$repository.DeploymentSettings.Get($project).VersioningStrategy.DonorPackage

Hope this helps someone else.

Thank you

Fabian

Hi Fabian,

I greatly appreciate your follow-up and sharing your findings! It’s something to have a closer look at. Please let me know if you have any questions or concerns going forward.

Best regards,

Kenny

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