microsoft / vso-agent

Visual Studio Team Services and TFS agent for Mac OSX and Linux
MIT License
132 stars 57 forks source link

Build can put directory into broken state. #235

Closed nbering closed 8 years ago

nbering commented 8 years ago

I just spent a couple hours trying to diagnose an issue with our build that turned out to be a build server state issue.

Our build process involves writing some files with generated code. For some reason our build process was running this incorrectly and over-writing a file for which the build should have been using the checked-in version. Not really a big deal, got that fixed.

The on-going issue is that the build agent was using the exact same working directory over again without reseting the files. So if the build process over-writes a source-controlled file it will continue to use the modified file in future builds as long as the file never changes in source-control. I think the build agent should at the very least do a hard reset on the build directory each time, so that uncommitted changes to the build directory are reverted to source-controlled versions. I've added this a build step in my build definition as a short-term solution.

Ideally each build should be done from a clean build directory. You could do this without having to do a brand-new network-intensive clone of the repo by using git work trees, making a new work tree for every build and then pruning them off when the build is completed, as some scheduled cleanup task, or before the next build starts.

If there's already some options to do these sort of things, I haven't found the documentation, and I'd love some instruction on how to administer the build server to solve these type of issues. For the record, I'm running on Ubuntu Linux on an Azure VM.

Edit

I should also mention that I'm using tfsgit for the source control provider from Visual Studio Team Services.

bryanmacfarlane commented 8 years ago

If you check the clean option on the repository tab of the definition, the agent will run git clean -fdx and git reset hard returning any dirty state before then doing a fetch of new code.

nbering commented 8 years ago

Thanks!