Link to home
Start Free TrialLog in
Avatar of sp70
sp70

asked on

Powershell script - How to monitor a folder for a new build?

Hello Experts!

In Powershell, how do you constantly monitor a folder or network share for changes such as a new build?  (There could be multiple builds every day in which case the folder name for the latest build has the following naming convention - 'Project Name - Test_yyyymmdd.#'  where # is an incrementing value for any given build on that day.)
  -- preferrably ties in with TFS to monitor when the latest successful build is complete

Thank you!
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mohamed Osama
You can use TFS itself to do the monitoring of the folder & running the Deployment scripts afterwards.
Is this TFS 2010 or 2008 ?
Both support continuous integration builds, you can also optionally configure your team build to run unit tests after the build is done & Deploy or not based on status of the test results.
For TFS 2008
For TFS 2010
Also , just in case you are a Powershell Fan & prefer the "do it yourself" approach , then why don't you take a look at the TFS deployer project.
it basically does what you are asking , a service listening for particular TFS events, then will run powershell scripts based on certain Criteria, 
Hope this helps.


Avatar of sp70
sp70

ASKER

Admin3k,
Thank you for the information.  I'm not in charge of the build system.  Your recommendation would probably fit my needs, but our lead developer will not put Beta software in this specific environment.  My needs (for Test) were basically to monitor a drop share for daily builds every morning and automatically set up my testing environments - a winsrv2k3 and an XP machine - based on this initial trigger.  I am looking for scripts or available utilities so I don't have to reinvent the wheel.
Someone told me about taking advantage of powershell by looking at the directory list in an array.  Admittedly, I'm VERY amature with regard to scripting & programming, so I'm diving into powershell.  
Thanks again for the info.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Another thing that came to mind, if you wish to configure your script to monitor the Build Drop location for new Folders, then Deploy based only on the fact that the new folder was created, some errors will occur.
The folder is created early in the team build process , to store the Build log first, then the binaries once the compilation is complete, this can take a very long time based on the Size of the solution you are building, any additional Unit tests that will run ,etc..
Also Partially succeeded, failed & canceled builds will still create their own folders, you need to ensure that what will be deployed is a proper successful build.
Thus the general direction to initiate the deployment Post the successful build event from the Build server.


Avatar of sp70

ASKER

Thank you both for wonderful solutions.

soostibi,
Being new to powershell, I'll try and get this to work for me, but not quite sure of the syntax at this point.

Admin3k,
Thank you for letting me know that I didn't have to put this on the TFS Server.  I'll also try implementing this approach.  I'm actually watching for Test Builds - though not currently of a given quality.  Part of my daily process is to check how the morning build proceeded before doing any sort of testing.

We are using TFS 2010.

The main problem I've been faced with (that appears to be getting resolved today) was that our entire dev and test team has NOT had administrative rights to our machines.  (No - I did not stutter - yes it's insane).  That's been the main cause of delay with actually implementing the recommendations posted here.

Thanks again for the help!
If your TFS administrator has enabled e-mail notification, it may be worth its while to use the project alerts tool in Team explorer to subscribe to the built completion events.
right click your team project in Visual studio>Project alerts & choose to be notified by e-mail (enter yours) when a build is completed.


Avatar of sp70

ASKER

Admin3k,
Email Notification - that's a touchy subject.  Long story short, ain't happening.  We're contracting with a company that's utilizing Lotus Notes and the Lead Dev already said that email integration will not be happening.  I only wish.  Believe me, they're very frustrated about many components of this project and the limitations that have been imposed on us.
Things seem tough.
now let us see , you need a standalone tool / script that will monitor builds being queued , finished & notify of complete / broken builds without sending an email 
There is a nifty little app that used to be part of TFS power tools, but  I believe it ships now With Visual studio, you should be able to find it somewhere in Start Menu >visual studio, called Build notification tool, it will do just that.