3
votes

My build artifacts disappear within 7 days or less. However the retention plan is not configured to delete anything until the artifact is at least 10 days old, but maybe I'm missing something with how retention plans work.

Some background: I use TFS via Visual Studio Online with a build agent that runs on a local server. I have a build definition in TFS that publishes an artifact to the local server using Artifact Type of "File share". The build definition uses the default retention plan -- keep for 10 days. enter image description here

The problem: Several times I have published an artifact, then within 1-7 days later the files were gone. Based on the log files in the _diag folder, the agent has an internal job named "Delete Artifacts" that is deleting these artifacts. The last time this happened, the job deleted artifacts created the same day, others from 8 days ago, and others from 16 days ago. (Also worth mentioning: The builds are still listed in the build history under Completed and the artifact is still listed in the build results' Artifacts tab, even though the files were deleted.)

Why is this Delete Artifacts job not honoring the retention policy and deleting artifacts too early? How can I fix this without configuring my builds to be retained indefinitely?

1
What do you mean publishes an artifact to the local server? Do you mean File share (Artifact Type)? How do you check the artifact missing? Do you check the artifact in build result page (Artifacts tab)?starian chen-MSFT
@starain-MSFT Artifact type is "File share". The published files are missing but the build itself is still listed under "Completed" in TFS. The artifact is still listed in the Artifacts tab. (Question updated)Keith
Check the artifact folder date modified time, then check the related log in [agent folder]_diag folder. Do you have another build agent on other machine? Are related artifacts be deleted too?starian chen-MSFT
You may setup a new build agent on another machine? I think the artifacts be deleted by other tool.starian chen-MSFT
@starain-MSFT I'll have to wait until the next time this problem happens because we republished the artifact recently and it hasn't disappeared yet. I checked the _diag folder but there are no logs before 2 days ago. I guess they are purged regularly? Also, this is the only build agent we have on any of our machines. Thanks for your help so far.Keith

1 Answers

4
votes

The problem was that each new artifact was being published to the same folder, and retention plans for old artifacts were deleting the new artifacts.

For example 1 month ago I published an artifact for WebApp1 to C:\artifacts\WebApp1, then today I published another WebApp1 artifact that went to the same folder. Then the retention policy kicked in for last month's build which caused it to delete C:\artifacts\WebApp1, thereby deleting the new artifact.

Making matters more confusing is the fact that if the retention policy is set for 10 days, the "Delete Artifacts" job may not necessarily run on day 10. In my case it took an additional 20 days.

I solved the problem by appending the build # to the artifact name so that each artifact folder has a unique name, for example: Artifact Name = "WebApp1-$(Build.BuildNumber)".