Optional phases in lifecycle are reverted to required

Hi,

Issue repro:

  • 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”.

I see that this was a recently completed feature request here - https://github.com/OctopusDeploy/Issues/issues/3415 and https://octopusdeploy.uservoice.com/forums/170787-general/suggestions/8475958-lifecycle-optional-phase-or-optional-environment

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.

Thank you!
Mallory

MakePhaseOptional.jpg

PhaseWasRevertedToRequired.jpg

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:

  1. Download latest (4.15.2) .NET octopus client (Octopus.Client.dll) through the Command line .NET Core zip download at https://octopus.com/downloads
  2. Copy the Octopus.Client.dll into C:\Program Files\Octopus Deploy\Octopus
  3. 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.

While using the UI, an optional phase can’t be skipped. It turns into a fully required one.

Hi Mallory,

Thanks for keeping in touch! I’ll take over this ticket whilst Rob is away. :slight_smile:

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.

Here’s a link to the LINQPad project: http://share.linqpad.net/futp9o.linq

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?

Hope that helps!
Mike

Instead of using the Octopus.Client.4.15.2

Use the Webpage. That’s the bug. Using 3.13.0 webpage create the lifecycle and try to get the behavior.

_WRD000.jpg

Well that’s actually pretty useful to know!

I have a group in my company located in Deer Park. If you need more active communication on the issue send an email and I’ll make myself available.

-T3

From: Octopus Deploy [mailto:tender2+df0f406f9f625a70e5816bda344a923ba74871151@tenderapp.com]
Sent: Wednesday, May 10, 2017 09:00 AM
To: Anthony Santaferra asantaferra@vistaprint.com
Subject: RE: Optional phases in lifecycle are reverted to required [Questions #11559] [questions #11640]

Hello T3!

Thanks for reaching out! We’ve received your request, and we’ll do our best to respond as soon as we can, usually within 24 hours.

We’ll send an email to you (at asantaferra@vistaprint.commailto:asantaferra@vistaprint.com) when we update your support request.

Alternatively, you can keep track of this conversation onlinehttp://help.octopusdeploy.com/discussions/questions/11640-re-optional-phases-in-lifecycle-are-reverted-to-required-questions-11559.

Thanks again!

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:

http://www.timeanddate.com/worldclock/australia/brisbanehttp://www.timeanddate.com/worldclock/australia/brisbane

I filed this in a separate thread and found it is related to items with tenants.

http://help.octopusdeploy.com/discussions/problems/54351-optional-phases-cant-be-skipped-in-ui

Cheers!

Hi T3,

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!

Hope that helps!
Mike