Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/pipelines/policies/retention.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Using retention policies, you can control **how many days** you want to keep eac
* Set the number of days to keep [runs](../process/runs.md)
* Set the number of days to keep pull request [runs](../process/runs.md)
* Set the number of recent [runs](../process/runs.md) to keep for each pipeline

::: moniker-end

::: moniker range="azure-devops"
Expand All @@ -91,9 +90,10 @@ Using retention policies, you can control **how many days** you want to keep eac

The setting for number of recent runs to keep for each pipeline requires a little more explanation. The interpretation of this setting varies based on the type of repository you build in your pipeline.

- **Azure Repos:** Azure Pipelines retains the configured number of latest runs for the [pipeline's default branch](../process/pipeline-default-branch.md) and for each protected branch of the repository. A branch that has any branch policies configured is considered to be a protected branch.
- **Azure Repos:** Azure Pipelines retains the configured number of latest runs for the [pipeline's default branch](../process/pipeline-default-branch.md) and for each protected branch of the repository. A branch that has any branch policies configured is considered to be a protected branch.
Only pipeline runs whose overall result is **Successful** or **Partially succeeded** are retained. Runs where deployments succeed in only certain environments or stages, and the overall run result is not **Successful** or **Partially succeeded**, are not retained.

As an example, consider a repository with two branches, `main` and `release`. Imagine the `pipeline's default branch` is the `main` branch, and the `release` branch has a branch policy, making it a protected branch. In this case, if you configured the policy to retain three runs, then both the latest three runs of `main` and the latest three runs of the `release` branch are retained. In addition, the latest three runs of this pipeline (irrespective of the branch) are also retained.
As an example, consider a repository with two branches, `main` and `release`. Imagine the `pipeline's default branch` is the `main` branch, and the `release` branch has a branch policy, making it a protected branch. In this case, if you configured the policy to retain three runs, then both the latest three runs of `main` and the latest three runs of the `release` branch are retained. In addition, the latest three runs of this pipeline (irrespective of the branch) are also retained.

To clarify this logic further, let us say the list of runs for this pipeline is as follows, with the most recent run at the top. The table shows which runs will be retained if you have configured to retain the latest three runs (ignoring the effect of the number of days setting):

Expand All @@ -110,6 +110,10 @@ The setting for number of recent runs to keep for each pipeline requires a littl
| Run 2 | release | Retained | Latest 3 for release |
| Run 1 | main | Not retained | Neither latest 3 for main, nor for pipeline |


Further, the number of days to retain is calculated from when the run is completed. For example, there are two runs on a main branch on Jan 19th. The run that completed later is retained.

:::image type="content" source="media/retention-run-completion-time.png" alt-text="Example of pipeline run retention where, for two runs on the same day, the run that completed later is retained.":::
- **All other Git repositories:** Azure Pipelines retains the configured number of latest runs for the whole pipeline.

- **TFVC:** Azure Pipelines retains the configured number of latest runs for the whole pipeline, irrespective of the branch.
Expand Down