I am getting errors using the Workspace.Checkin command in TFS because the files I am trying to check in are part of a Gated build definition. There are lots of people asking how to override a gated check-in using the TFS API. But a very different question is this: what if I actually want to perform the gated check-in, programmatically? How can I trigger this in TFS API?
What I want to do is:
- Perform a normal check-in operation of a set of pending changes
- Receive information about the gated build that was launched
- Either subscribe to a completion event for that build, or poll the build until it is complete.
- Continue if the build was successful, and changes were committed (get the resulting changeset if possible)
- Stop if the build was not successful, and report the error.
I could not find anything out there to answer this question; perhaps it is such an edge case that I'm the only one crazy enough to want to do this. That said, my need for this is legitimate. The only thing I can figure is that I would need to go through the lower-level functions of the gated check-in process: 1) Walk through the build definitions to see if the path of any of the files coincide with any of the paths in any of the gated builds. 2) If an intersection exists, create a shelveset of the pending changes 3) Queue a new build of the gated definition using the shelveset 4) Query the build definition and refresh the information until the build status is completed 5) If the build was successful, unshelve the pending changes, and then check-in using an override.
However, note that even if I do these steps, the resulting build won't look like a gated build at all. Policy override notifications will be sent, and the only way of letting someone know that a build was actually performed would be to include such information in the policy override comments. Is there a more direct way to do this that would make it look like any other gated build?