2

I'd like to be able to stop build for some build definitions programmatically. First I thought about creating some event handler (soap service or TFS plugin) to solve this issue. But unfortunatelly it seems like there isn't appropriate event in TFS (that would be raised when build is just started).

Is there the way to solve this issue?

Thank you!

Elena

Upd: The problem has been solved by call of cutom build task in the very first target in TFSBuild.proj

Elena
  • 266
  • 3
  • 12
  • You should add that as an answer and mark it as correct then. – Betty Oct 23 '12 at 09:23
  • 1
    Elena, could you describe how you stop build from task? –  Dec 12 '13 at 16:57
  • 1
    Custom build task checks some conditions. If current build should be stopped I call Log.LogError("Some error message here"), where Log = Microsoft.Build.Utilities.Log. The logging of error will stop build automatically. – Elena Dec 13 '13 at 11:01

1 Answers1

1

Most build monitors seem to periodically poll TFS to see if there's any new builds, this obviously won't work for you as there will be too much of a delay to cancel the build.

I suggest you modify the build template to do a web request right at the start. Or just putting the logic to cancel the build in the actual template.

May i ask why you need to cancel builds anyway? there may be a better alternative.

Betty
  • 9,109
  • 2
  • 34
  • 48
  • Thank you, Betty. We don't use build process template (still use tfsBuild.proj). So this way will not work. The build canselation is needed since there are some actions during build that should be done only if several pre-conditions are true. Check those conditions before starting build is a quite long process and these checks can be automated. So that would be nice if user just starts build in TFS and it will be stopped automatically (with appropriate message in log) if conditions are false. – Elena Oct 18 '12 at 09:42
  • 1
    tfsbuild.proj still uses a upgrade.xaml template, also you can insert custom actions into the proj file. – Betty Oct 18 '12 at 09:54