Search code examples
azure-pipelinesreleaseartifactretention

What controls the retention of builds in Azure cloud pipelines?


We have a pretty common situation with a build pipeline and a deployment pipeline, where the build pipeline produces a build artifact (in our case, powershell and json files in a .zip) and a deployment pipeline uses that artifact (and a VM image) to deploy Azure resources (in our case, VMs).

We have a problem with the retention of the build artifacts, as in - they are – my theory – in the builds folder in azure and subject to retention rules there.

Artifact retention • Project settings

enter image description here

The problem is that older “artifacts” disappear with no explanation – and even though we have the base VM image still available, we can no longer created VMs for older versions of our software. Specifically, they disappear as options from this drop down in the deployment pipeline:

enter image description here

I thought that drop down is being fed from the list of files/artifacts available in the build or staging folder of the build pipeline. Recent research by fellow developers have disproved my theory. There is no documentation from Microsoft over what feeds that drop down and what controls the availability of artifacts there – though we suspect is still based somehow on the build pipeline. All the while, it seem that whilst using Azure pipelines, there is no way to keep older (in terms of either age or “# builds ago”) builds available for deployment – and this is simply hard to believe.


Solution

  • For Build Artifacts Retention:

    As far as I know, three points can affect the retention time.

    1. Build Retention Policy. From you screenshot, you have set the 30 days for Days to keep artifacts, symbols and attachments. This retention policy will keep artifacts for 30 days.

    If the policy is not overwritten, the artifacts will be deleted after 30 days

    1. Release Retention plicy. If the artifacts are used in release, the release retention policy will overriede the build retention policy.

    A single release: you could check this option in Release -> Retention

    enter image description here

    All Release: you could check it in Project Settings-> Release Retention.

    enter image description here

    The artifacts retention policy will follow release retention policy.

    1. If the build or associated release has been retained , the artifacts will keep forever(override all policies). Build -> Retain, Release -> Retain indefinitely

    For example:

    enter image description here

    This Retain option could keep the build forever.

    If you want to keep the old artifacts , you could use this option.

    Here is a doc about build and release retention policy.

    For the Version Drop Down list:

    The dropdown list shows the successful build versions. Whether it contains artifacts or not, they will be displayed in list.

    The version corresponds to the build version number.

    For example:

    enter image description here