I’m trying to use Octopus.Client.dll with PowerShell to change the builtin package repository retention policy of multiple octopus instances but I can find the right way. I’ve been digging through the documentation and the dll but can’t find anything. I can see the model BuiltInFeedResource but the Octopus.Client.Repositories.BuiltInPackageRepositoryRepository does not have the option to modify. Is there any way I can do this with PowerShell?
Thanks for your response. However, I wasn’t able to make it work. I’m getting an invalid cast exception.
System.InvalidCastException: ‘Unable to cast object of type ‘Octopus.Client.Model.NuGetFeedResource’ to type ‘Octopus.Client.Model.BuiltInFeedResource’.’
Thanks for providing the link for the compatibility page. I have changed the Octopus.Client version to 4.47.0.
I have also tried your suggestion but unfortunately it did not work for me. I am getting this error:
System.Exception: ‘The document does not define a link for ‘Values’’
However, I found another way to make it work.
var link = repository.Client.RootDocument.Links["RepositoryConfiguration"];
var config = repository.Client.Get<BuiltInRepositoryConfigurationResource>(link);
config.DeleteUnreleasedPackagesAfterDays = 10;
repository.Client.Put<BuiltInRepositoryConfigurationResource>(link, config);
I have also converted my code to a PowerShell script since it’s what I needed originally. (I will be running the script in Octopus.) Here’s how I did it in PowerShell.