Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute PowerShell script when a build is stopped in build explorer

I have got a requirement wherein I need to execute a PowerShell script when someone stops a running build in TFS -> Build explorer.

Is there any event or method that I can hook my code into to achieve that?

For far I only know Pre & Post-build events but those won't help me here.

Note: we are using TFS for source control and for builds. And using Octopus Deploy for development on various environments.

like image 694
Pradeep Avatar asked Apr 19 '16 13:04

Pradeep


People also ask

How do I make a PowerShell script executable?

Open Start. Search for PowerShell, right-click the top result, and select the Run as administrator option. Type the following command to allow scripts to run and press Enter: Set-ExecutionPolicy RemoteSigned. Type A and press Enter (if applicable).

How do I run a ps1 file from command prompt?

Running a PowerShell script from the Command Prompt If you would like to run a PowerShell script in CMD, you'll need to execute it by calling the PowerShell process with the -File parameter, as shown below: PowerShell -File C:\TEMP\MyNotepadScript. ps1. PowerShell -File C:\TEMP\MyNotepadScript.

How do I run a PowerShell script from the command line with parameters?

To run scripts via the command prompt, you must first start up the PowerShell executable (powershell.exe), with the PowerShell location of C:\Program Files\WindowsPowerShell\powershell.exe and then pass the script path as a parameter to it.


1 Answers

Write TFS Server side plugin, which can monitor for that information by subscribing to the events you're interested of.

If you google for "how to create TFS server side plugins" you'll find plenty tutorials how to create one.

For ex: https://roadtoalm.com/2012/03/29/create-tfs-event-subscription-programmatically-with-tfs-api/

You could subscribe to BuildStatusChangedEvent event, and then do something.

like image 166
Erti-Chris Eelmaa Avatar answered Sep 28 '22 20:09

Erti-Chris Eelmaa