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.
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.