Keith
Keith

Reputation: 21264

TFS build artifacts are disappearing

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?

Upvotes: 3

Views: 1675

Answers (1)

Keith
Keith

Reputation: 21264

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)".

Upvotes: 5

Related Questions