问题
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
回答1:
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.
回答2:
I had written the Assembly Version update code in Powershell and could not find the slimier code "OverrideGatedCheckIn = true
" for Powershell and all I did was moving assembly version files (SharedAssembly.vb & SharedAssembly.cs) to a folder called SharedAssembly and excluding them to considering for the GatedCheck-In process.
来源:https://stackoverflow.com/questions/8049739/can-i-bypass-gated-check-in-build-after-checking-a-file-in-during-a-separate-bui