Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I bypass Gated Check-In build after checking a file in during a separate build process? TFS 2010

Tags:

msbuild

I have 2 build definitions set up for a solution, 1 is a nightly build that is triggered every night and the other is a Gated Check-In build that will trigger when developers try to check new changes into source control. The nightly build is using a custom template that increases assembly versions using method that has been slightly modified from the Ewald Hoffman method. When a file is checked in via the custom activity to check files in, i get the build error:

Your check-in could not be completed because it affects the following gated build definitions \Project\GatedBuld. To complete your check-in you will need to queue a build of the shelveset Gated_2011-11-08_09.31.42.6934;DOMAIN\TFSBuildAccount.

At present I have not been able to find a way to bypass this gated check-in build (CI builds are prevented using the *NO_CI* check in comment).

I have tried setting the "Override check-in validation by build" permission for the build service account (via Security for the gated build), but as far as I know this will only prevent the gated build when checking code in manually (via a check box presented in the Gated Check-in dialog). What I'm looking for is a way to bypass a gated build when checking changes in automatically

Any suggestions?

As always, thanks for any help in advance

like image 695
Vermin Avatar asked Nov 08 '11 11:11

Vermin


1 Answers

When you checkin your changes programmatically, you can create a WorkspaceCheckInParameters object and set its OverrideGatedCheckIn property to true. The following code would bypass gated checkin (and also CI):

            var pendingChanges = workspace.GetPendingChanges();
            if (pendingChanges.Any())
            {
                WorkspaceCheckInParameters parameters = new WorkspaceCheckInParameters(pendingChanges, BuildCommonUtil.NoCICheckInComment)
                {
                    OverrideGatedCheckIn = true,
                };
                workspace.CheckIn(parameters);
            }

Note that you need to grant the permission to bypass gated checkin on the account that performs the checkin for all affected build definitions. In this case, it is the build service account of the Nightly build.

like image 113
Duat Le Avatar answered Oct 14 '22 11:10

Duat Le