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.
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).
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With