Update Lifecycle, Phase, Environment via Client (or API)?

Is it possible to script the addition and removal an Environment from a Lifecycle Phase using the Octopus Client? Or should I look into doing this via the API?

Hi @dwhite,

Thanks for reaching out! You can do this with bout the API and the Octopus.Client (which is basically a wrapper around the API).

If you rather use the Octopus Client (which I recommend over using raw API), you basically need to

the following is mostly pseudo-c#

  1. run repository.Lifecycles.Get(lifecycleId) to get your lifecycle.
  2. remove/add the desired phases from the Lifecycle object you received in (1).
  3. Finally, save the modified lifecycle object back to the database using intorepository.Lifecycles.modify(lifecycle).

Let me know if that helps. Otherwise I can jump into my IDE and write actually working code for you.

Best regards,
Dalmiro

Hi Dalmiro,

Thanks. You have helped by pushing back my ignorance a little further. I was missing the final line to save the changes. :slight_smile:

warm regards,
david

1 Like

Glad to hear that! Cheers

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