Return to site

Execute Batch File After Tfs Build Notification

broken image


  1. Execute Batch File After Tfs Build Notifications
  2. Auto Execute Batch Files
  3. Execute Batch File After Tfs Build Notification 2017
Active3 years ago

ProblemI have a build definition existing in TFS (which i cannot change). I am automating our File gathering process, in which i need to execute this build definition, get the drop location and copy those output to desired location.

Now execute the batch file and then provide the parameter values, it will automatically pick all the files from the folder specified and execute it. This script will also create a output log file which has all the information about which script it executed and it's result (from SQL Server result set). Sending Email Notification from VSTS/TFS Build. This is usually done to notify users of a build failure or to give information like results from a test run triggered by the build. The files included in the build task. The contents of the default task.json look like following. 2 Responses to How to run batch file after TFS build. Prashant says: February 9, 2014 at 11:43 am. Hi Chan, Can you send me xaml template that does this batch file execute i have batch file to be executed on remote server after TFS build and publish website. Please email me to vi2psn@yahoo.com. Thanks, Prashant.

Solution: We already have a batch file which does file copy operations. So i am trying to integrate everything in it.I started the build using TFSBuild.exe (Command line tool). Provided server path, build definition name. Build completed successfully.

My problem is i am not able to get the name of the folder (or any build completion details) where the currently executed build definition has dropped the output to append to drop location.I want to fetch the value of Drop folder after build completion.

(If there is any better/simpler method, it would be helpful)

Thanks in advance.

Dot_Refresh
Dot_RefreshDot_Refresh

3 Answers

You can specify the droplocation as a part of queuing the build using TFSBuild.exe. 'TFSBuild.exe help start' on the command line should help you with that.

On a side note, if you are still using batch file to copy files from drop location to somewhere else for packaging then the process is not automated at all in my opinion. Customize your build process, use WIX to package the code. Right after the source code compilation is over you can kick off the WIX package and the final output of your build would be an MSI for deployment!

Isaiah4110Isaiah4110

Execute Batch File After Tfs Build Notifications

If at all I have understood your problem, $env:BUILD_ARTIFACTSTAGINGDIRECTORY should help you!Thanks for posting this question!

Shadja ChaudhariShadja Chaudhari

Looking at all the inputs and comments over the internet, there seems to be no way to extract the Updated Build number/name/ drop folder name from TFSBuild.exe.

So, i have managed a Workaorund. (Bit tedious, but works)

Push all the output of TFSBuild.exe command to a txt file.

TFSBuild.exe start 'TFS Server Path' >> 'SOME TXT FILE'

Parse the txt file and extract the line containing value 'Updated Build number:' and get the output folder name.

As i know the Drop location where all the builds are dropped, append the foldername and get the files.

Dot_RefreshDot_Refresh

Not the answer you're looking for? Browse other questions tagged tfstfs2010tfsbuildbuild-definition or ask your own question.

Active6 years, 6 months ago

My task is:

Execute Batch File After Tfs Build Notification

after TFS build

1) On a server X stop file Example.exe

2) Copy files from Drop Location into server X

3) Run a brand-new version of Example.exe on a server X

I'm updating DefaultTemplate.xaml in TFS 2012, Visual Studio 2012.I'm entering InvokeProcess activity that runs Do.bat script.

My Build Agent copies files to server X and then runs file X...Do.bat

Cmd

after TFS build

1) On a server X stop file Example.exe

2) Copy files from Drop Location into server X

3) Run a brand-new version of Example.exe on a server X

I'm updating DefaultTemplate.xaml in TFS 2012, Visual Studio 2012.I'm entering InvokeProcess activity that runs Do.bat script.

My Build Agent copies files to server X and then runs file X...Do.bat

Do.bat is something like

So, the problem is the Example.exe is running on a Build Agent, not on server X.

How can I make build agent run an executable file on another server?The additional question - is it worth using bat files as scripts in TFS Build?

Kirill Khotimchuk
Kirill KhotimchukKirill Khotimchuk

1 Answer

PsExec is a SysInternals tool that will run a process on a remote computer.

PowerShell is also able to launch a process remotely.

As to your additional question, I have generally found it more worthwhile customizing my tfs builds writing build activities in C# and/or using the built-in activities and customizing the build template in xaml. Not fun, but I find external scripts run into more permissions issues and are difficult to debug. I've tried them, and then I usually end up back in C#.

Auto Execute Batch Files

Nate HekmanNate Hekman
Got a question that you can't ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Execute Batch File After Tfs Build Notification 2017

Not the answer you're looking for? Browse other questions tagged deploymentbatch-filetfs2012workflow-activitybuild-agent or ask your own question.





broken image