Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I programmatically checkin code in TFS with policy override?
    primarykey
    data
    text
    <p>I'm trying to checkin code from a c# program in a part of TFS repository which will trigger a gated checkin build and also a continuous integration build.<br> This is my code so far:</p> <pre><code> public static void Checkin(string path, string comment) { var wsInfo = Workstation.Current.GetLocalWorkspaceInfo(path); var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(wsInfo.ServerUri); tfs.Connect(ConnectOptions.None); var vcs = tfs.GetService&lt;VersionControlServer&gt;(); var ws = vcs.GetWorkspace(path); var fullPath = Path.GetFullPath(path); var change = ws.GetPendingChangesEnumerable().Where(p =&gt; p.LocalItem == fullPath).ToArray(); ws.CheckIn(change.ToArray(), comment); tfs.Dispose(); } </code></pre> <p>what is basically happening is that I get a GatedCheckinException say that there is an affected build defintion. I would like to do the checkin with the commonly known bypass to avoid triggering the gated checkin. I've been struggling with the altenate Checkin functions without success.<br> <br> Any idea?</p> <p><strong>UPDATE:</strong> Thanks Aghilas Yakoub for the link. For completeness, here is the code to do the checkin with override that worked for me:</p> <pre><code>var wip = new WorkspaceCheckInParameters(change, comment) { OverrideGatedCheckIn = ((CheckInOptions2)vcs.SupportedFeatures &amp; CheckInOptions2.OverrideGatedCheckIn) == CheckInOptions2.OverrideGatedCheckIn, PolicyOverride = new PolicyOverrideInfo("Check-in from the build.", null) }; ws.CheckIn(wip); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload