admin管理员组文章数量:1317898
Background:
We have an on-prem Azure DevOps build server with a number of agents. We have recently run out of disk space on it and discovered that although we have 30 days retention policies set up in Azure DevOps there are build artifacts nearly a year old on the file system. I have read the articles linked below, and used them to check our project and anisation retention policies. The age of the artifacts on the server indicate these are being ignored.
Screen Shots:
Below is a screen shot of the project settings for retention.
Below is our release retention settings:
Questions:
- How do I set a policy that will kill off the build agent artifacts from the file system for everything except the last successful build?
- Or failing kill them off after X days.
- Why can I not edit any of the setting underneath "Retention policy settings", except the "Retain build" checkbox? All others are disabled.
- What does unchecking "Retain build" actually do?
Reference:
- ;tabs=yaml
UPATE: I have now implemented the "maintenance job" for the build agent pool, following the advice in on of the comments.
Background:
We have an on-prem Azure DevOps build server with a number of agents. We have recently run out of disk space on it and discovered that although we have 30 days retention policies set up in Azure DevOps there are build artifacts nearly a year old on the file system. I have read the articles linked below, and used them to check our project and anisation retention policies. The age of the artifacts on the server indicate these are being ignored.
Screen Shots:
Below is a screen shot of the project settings for retention.
Below is our release retention settings:
Questions:
- How do I set a policy that will kill off the build agent artifacts from the file system for everything except the last successful build?
- Or failing kill them off after X days.
- Why can I not edit any of the setting underneath "Retention policy settings", except the "Retain build" checkbox? All others are disabled.
- What does unchecking "Retain build" actually do?
Reference:
- https://learn.microsoft/en-us/azure/devops/pipelines/release/artifacts?view=azure-devops
- https://learn.microsoft/en-us/azure/devops/pipelines/policies/retention?view=azure-devops&tabs=yaml
UPATE: I have now implemented the "maintenance job" for the build agent pool, following the advice in on of the comments.
Share Improve this question edited Jan 24 at 11:07 Dib asked Jan 22 at 15:50 DibDib 2,0932 gold badges31 silver badges47 bronze badges 4- devops.stackexchange may be a better place to ask this question. – tevemadar Commented Jan 22 at 16:18
- You have default pipeline retention policy on your screenshot, the build artifacts should be deleted along with the build/release run. So may i know if you checked the old pipeline run, is it retained manually or by release? please check link here. – wade zhou - MSFT Commented Jan 23 at 2:04
- Are you publishing your build artifacts to the build agent's file system, or to Azure DevOps? The policies you're referencing only apply to the latter; if you're publishing artifacts to the agent, those won't be cleaned up automatically. There's really very little reason to not publish to Azure DevOps. – Daniel Mann Commented Jan 23 at 3:40
- 1 Also note that the retention settings aren’t limited to just 30 days. You have 25 releases, some of which can be be older, and the 3 runs per pipeline per branch (other than the default branch). – bryanbcook Commented Jan 23 at 14:16
2 Answers
Reset to default 2The policies that you've linked are the retention settings for how long to keep published build artifacts within Azure DevOps not the build agents themselves. For example, if you navigate to the pipeline execution history for a pipeline and your pipeline publishes a build-artifact -- the system will keep the artifacts for 30 days for pipelines that were run on the default branch. After 30 days, the pipeline run is expunged from history. You can override this policy at each pipeline run and opt to "retain" the artifacts.
The retain build setting of the release pipeline marks artifacts produced by the linked build to be retained. This ensures that your build artifact isn't included in the build artifact retention policies if it's associated to a release that is being retained. This setting requires a Project Administrator setting to change.
Related to your scenario and disk space consumption. It's helpful to understand that the Microsoft provided cloud-hosted agents are recycled after every job. This helps to create a much more deterministic build: your pipeline builds what's defined in source and is free from side-effects from previous builds.
Azure DevOps provides several different strategies to help you emulate this behavior:
- Azure DevOps Virtual Machine Scaleset agents. Runs your agents in a vm scaleset that scales based on demand. This strategy can also define policies to tear down vm when it's idle.
- Scaling Azure DevOps agents in Kubernetes using KEDA. Runs a new container image per pipeline job.
- Managed Azure DevOps Pools. Previously in private-preview, Microsoft maintains the infrastructure for your agents; you provide the custom disk image.
If you're running your self-hosted agents on dedicated virtual machines, you should adopt a practice of recycling the agents frequently (at least weekly) to prevent common issues related to side-effects and maintenance issues, like disk-space availability. For example:
- Create a scheduled pipeline that runs in the Microsoft provided cloud-hosted agent pool that uses the REST API to take the agents offline so that new builds are not queued.
- Get Agent Pools
- List Agents
- Update Agent (set
enabled: false
)
- Setup a cron job or scheduled task on the agent to perform any necessary clean-up activities. At the end of the job, reboot the machine which will re-enable the agent on start-up.
I assume you are asking about build artifacts (and not build agent working directories). Build artifacts are produced by a build pipeline and are stored either in the Microsoft SQL Server database that is the backing data store for Azure DevOps or on a file share. (Note that the file share doesn't need to be on the same host as the Azure DevOps server and different build pipelines can use different file shares on different host machines.)
There are "global" retention settings at the Organization (aka collection) level. These can be overridden at the Project level. Older versions of Azure DevOps allowed overriding at the pipeline level but newer versions dropped support for this. I'm guessing your screenshot is either of the pipeline or of the project where the current user doesn't have the proper admin rights.
The "Retain" checkbox will retain a build forever regardless of retention policy until the retain is unchecked/removed.
When a release pipeline consumes a build artifact of a build pipeline, the release pipeline creates a "retain" on the build. A set of retention policy settings that aggressively prune builds will have no effect if every release is kept. Similarly, test management runs may retain releases.
You can use the REST API to find out what is retaining the build. And you can use the API to clear the "retain" flag regardless of dependencies. After a "retain" is cleared on an old build, the normal retention policy check cycle should delete the build.
本文标签: azure pipelinesPolicy to delete artifacts from file system of dev ops build serverStack Overflow
版权声明:本文标题:azure pipelines - Policy to delete artifacts from file system of dev ops build server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742035552a2417271.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论