Update a phase of a lifecycle to be optional in Octopus UI (see “MakePhaseOptional.jpg”)
In powershell, get the lifecycle and call modify on the lifecycle as it was received (see snippet below, full script used in PowershellScriptFakeModifyLifecycle.jpg)
$lifecycle = $Repository.Lifecycles.FindByName(“Azure RD”)
$Repository.Lifecycles.Modify($lifecycle)
Check lifecycle again in UI
Expected:
Phase should still be optional
Actual:
Phase is now required again (see PhaseWasRevertedToRequired.jpg)
I did some digging and saw that the Repository lifecycle object is missing the “IsOptionalPhase” property. I’m assuming that the Octopus powershell client is not correctly respecting the existing value, and is overwriting values with “false”. In fact, when looking at the audit (see AuditLog.jpg) after modifying an unrelated property on a different phase in the lifecycle, I can see that the phase is being reverted to “false”.
We have not found any easy workarounds at the moment; We are currently modifying lifecycles (adding new environments to phases) on a regular basis, and the scripts that do that use the repo.lifecycles.modify() call. We looked into switching it to the REST API call, but there’s a lot of overhead since the API calls use the full lifecycle for GET/POST in a true restful fashion, instead of allowing updates to just the phase we need to change.
Please let me know if there is any additional info from me that you need.
Hi Mallory,
It looks like the new version of Octopus.Client had not yet been published to account for the new IsOptionalPhase property on the lifecycle. I have pushed version 4.15.1 to the downloads page so please download the latest version of the command line tools and try again.
Let me know if you encounter any further difficulties with this and apologies for any inconvenience.
Cheers,
Rob
Hmm. We are still seeing lifecycle phases revert from optional to required when modifying lifecycles through the Octopus.Client dll. I tried again this morning with the new 4.15.2 release from today, and no luck.
Repro:
Download latest (4.15.2) .NET octopus client (Octopus.Client.dll) through the Command line .NET Core zip download at https://octopus.com/downloads
Copy the Octopus.Client.dll into C:\Program Files\Octopus Deploy\Octopus
Run the powershell script attached in original post.
Note that we’re using the Octopus Client DLL similar to how OctoPosh (https://github.com/Dalmirog/OctoPosh) does to write our scripts; we’re not using octo.exe.
Thanks for keeping in touch! I’ll take over this ticket whilst Rob is away.
I’ve tried to reproduce this problem using Octopus.Client.4.15.2 in a C# script in LINQPad. I’m sorry to say I can’t reproduce the same behaviour: it’s working exactly as I’d expect it to.
var repo = new OctopusRepository(new OctopusServerEndpoint("http://localhost:8065"));
repo.Users.SignIn(new LoginCommand { Username = "admin", Password = "Password01!" });
var before = repo.Lifecycles.FindByName("Optional Lifecycle");
before.Phases.Dump("Before");
var after = repo.Lifecycles.Modify(before);
after.Phases.Dump("After");
I’ve attached a screenshot of the results where the lifecycle is loaded, and then saved correctly.
Where to from here?
I would suggest trying this LINQPad script, or double checking you’re using the right version of the Octopus.Client library. Perhaps your PowerShell session has cached the dependency, and you need to force load or restart PowerShell?
PS: Our team is located in Brisbane, Australia, and we usually respond between 9am and 5pm on weekdays Brisbane time. You can see what time it is for us here:
Yep, I think we’re working with you on that other thread. That problem, as you mentioned, is a bug in the calculation of the lifecycle progression specific to tenants. It looks like the problem Mallory was having is that the Lifecycle itself was not being saved correctly due to a problem with the SDK.
Mallory: I’d be keen to hear back from you to make sure we’ve solved your problem!