I am running Octopus Deploy v 2.6.0.778. Every time the retension policy task runs it fails with the following error:
Value cannot be null.
Parameter name: key
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at Octopus.Server.Communications.Lifecycles.LifecycleProgression.GetRelevantDeploymentsByEnvironment(IEnumerable1 deployments) in y:\work\refs\heads\release\source\Octopus.Server\Communications\Lifecycles\LifecycleProgression.cs:line 175
at Octopus.Server.Communications.Lifecycles.LifecycleProgression.Evaluate(Boolean releaseHasUnresolvedDefect, IList1 deployments, List1 allEnvironments, Lifecycle lifecycle) in y:\work\refs\heads\release\source\Octopus.Server\Communications\Lifecycles\LifecycleProgression.cs:line 43
at Octopus.Server.Orchestration.Retention.RetentionPolicyApplier.Receive(ApplyNextRetentionPolicyBatchCommand command) in y:\work\refs\heads\release\source\Octopus.Server\Orchestration\Retention\RetentionPolicyApplier.cs:line 134
at Pipefish.Actor.OnReceivingTyped[TBody](Message message) in y:\work\3cbe05672d69a231\source\Pipefish\Actor.cs:line 113
The attached screen shot is from the diagnostic page.
Thanks for getting in touch and I’m sorry about the issues you are having with the retention policy.
From the looks of things, there seems that you have a deployment that for some reason have no environment set (not sure how this would have happened but a few versions back we had a bug that allowed deleting things that still had references to it, so this may be the cause of this).
I have put together a powershell script that you can execute in the Script Console that hopefully can shed some light at what is causing this issue.