开发者

Avoiding clean failing (and hence build) from something locking a build directory

开发者 https://www.devze.com 2023-02-27 05:47 出处:网络
The windows cmd prompt is one culprit--I\'ll sometimes cd into one of my build subdirectories to check something 开发者_开发知识库out and unless I close down the console or cd out somewhere else, my n

The windows cmd prompt is one culprit--I'll sometimes cd into one of my build subdirectories to check something 开发者_开发知识库out and unless I close down the console or cd out somewhere else, my next build is of course going to fail because it can't delete the build directories.

So sure, I can just exit the cmd prompt or cd out, but I forget and before I know it, my CI server has all these failed builds just because of this.

I can imagine there's no way Ant can force the deletion, but is there another good strategy? Can Ant be told to try to delete but not fail if it can't? I can see this might not be a good idea, but it's something I'd have to weigh up specifically for my scenario.

Or at least is there a cmd.exe option or alternative cmd line that doesn't lock the current working directory?


Windows won't allow you to delete a directory if someone else is in that directory. It doesn't matter if its a console window or a Explorer window. There's no real way around it except by killing the process first.

What Continuous Integration tool are you using? If you're using Jenkins or Hudson (Jenkins forked off of Hudson a few months ago) you can view the working directory by clicking on the Working Directory link on the left side of the browser window. That'll give you a view into your working directory (so you can check everything) but won't lock up the directory and prevent deletion.

If you have to get on the build machine, disable the job, so the build server won't attempt to build while you're checking things out.


First, I don't think you should be logging into your build server and looking at build subdirectories so often that this is a consistent problem. Are you working on your build on the buildserver itself? If so then you're better off making sure you can run the exact same build script from a developer machine and can work on it locally. Consistency is key.

Beyond that, you can kill the sessions hosting the command window. The command windows will be part of interactive sessions. You can setup a scheduled process to find and kill inactive but left-on sessions. Here's a good guide for doing it interactively but this can be easily scripted.

http://www.howtogeek.com/howto/windows/command-line-hack-for-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections/

You'll have to define your own criteria for when to auto-kill sessions.


You may want to explore 'quiet' and 'failonerror' attributes of the ant delete task. Be careful though.


Could it be virus scanning that is causing you issues? Perhaps just excluding that directory would work.

0

精彩评论

暂无评论...
验证码 换一张
取 消