Sign in Start for free

Deleting policies

How to delete policies and their published versions from Platform Hub

When you no longer need a policy, you can delete it from Platform Hub. Deleting a policy removes its OCL file from your Git repository and its published versions from Octopus.

You can delete a policy from the branch or tag you’re viewing. Octopus only deletes the versions published from that branch or tag, unless you choose to delete all versions from the default branch.

If you only want Octopus to stop evaluating a policy, deactivate it instead. You can re-activate it again later.

You need the PlatformHubEdit permission to delete a policy.

Before you delete a policy

You can’t delete a policy’s active version. Deactivate the policy from the Versions tab on the edit policy page first.

  • When you delete a policy from a branch or tag, Octopus prevents the delete if the active version was published from that branch or tag. An active version published from somewhere else doesn’t stop the delete.
  • When you delete all versions, Octopus prevents the delete if any version is active.

Delete a policy

  1. In Platform Hub, go to Policies.
  2. Select the branch you want to delete the policy from.
  3. Open the overflow menu (…) for the policy and select Delete.
  4. On the default branch, choose which versions to delete. See Delete all versions.
  5. Select Delete.

Octopus commits the change to the branch and deletes the versions published from that branch.

You can’t undo deleting a policy.

What Octopus deletes

Where you delete from Git repository Published versions
A branch Removes the policy’s OCL file from that branch Deletes the versions published from that branch
The default branch, with All versions selected Removes the policy’s OCL file from the default branch Deletes every version, wherever it was published from
A tag No change Deletes the versions published from that tag

Octopus never changes the policy’s file on other branches or tags.

Deleting a policy doesn’t remove its history. Policy evaluations already recorded in the audit log and in task logs stay, and Octopus records the delete in the audit log.

Delete all versions

On the default branch, the delete dialog asks Which versions do you want to delete? when other branches or tags have published versions of the policy:

  • Only versions from the default branch deletes the versions published from the default branch. This is the default.
  • All versions deletes every published version of the policy, including versions published from other branches, tags, and branches or tags that no longer exist.

You can only delete all versions from the default branch. All versions is unavailable while the policy has an active version.

Delete versions published from a tag

A tag can’t be changed, so Octopus doesn’t remove the policy’s file from a tag. Instead, you can delete the versions published from it.

  1. Select the tag in the branch selector.
  2. Open the overflow menu (…) for the policy and select Delete versions.
  3. Select Delete versions.

Delete versions is only available when the policy has versions published from the tag.

Protected branches

You can’t delete a policy from a protected branch, because Octopus can’t commit to it. Delete is unavailable and shows that the branch is protected.

To delete a policy from a protected branch:

  1. Remove the policy in a pull request. You can delete the policy from an unprotected branch in Octopus, then select Create pull request next to the branch selector. This link is available when your Platform Hub repository is hosted on github.com or gitlab.com.
  2. Merge the pull request into the protected branch.
  3. In Octopus, select the protected branch. The policy now shows as Removed from Git.
  4. Delete the policy. See Policies removed from Git.

Policies removed from Git

When a policy’s OCL file is removed from a branch outside Octopus, such as through a pull request, the versions published from that branch still exist in Octopus. If one of those versions is active, Octopus keeps evaluating it. The policy stays in the list with a Removed from Git status so you can clean it up.

Renaming a policy’s OCL file has the same effect, because the file name is the policy’s slug. The old name shows as Removed from Git, and the new name appears as a policy that hasn’t been published.

For a policy that’s been removed from Git, you can:

  • Deactivate it
  • Delete it, including on a protected branch

Octopus only deletes the published versions, and doesn’t commit anything to your repository.

You can’t open, edit, or publish a policy that’s been removed from Git.

Removed branches and tags

When a branch or tag is deleted from your Git repository, the policy versions published from it still exist in Octopus. The branch selector keeps listing the branch or tag with a Removed label for as long as it has published versions.

Select a removed branch or tag to see the policies with versions published from it. Each policy shows as Removed from Git. You can deactivate and delete these policies, but you can’t create or edit policies there.

After you delete the last policy with versions published from a removed branch or tag, it no longer appears in the branch selector.

Version notes

  • Deleting policies with their published versions is available from Octopus Server 2027.1.1326.