I have a trigger to build projects on check-ins. But I want to add some check and cancel build in some cases.
I created a Task with condition I want to check. I can run this task using TFSBuild.proj file with code like this where CheckIfBuildNeeded
is the name of my Task:
<Target Name="BeforeCompile">
<CheckIfBuildNeeded>
.....
</CheckIfBuildNeeded>
</Target>
So, the answer is, how can I cancel/stop build from Task's Execute()
method or any other place? How can I get the Build object?
I know I can get builds from TFS with this code. But to do something with build I, naturally, need to know it's ID.
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://foo.bar/tfs");
IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
Take a look at the Error Task.