Click here to Skip to main content
15,891,883 members
Articles / DevOps
Tip/Trick

Enabling Gated Check-in using Visual Studio Team Services

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
4 Feb 2017CPOL2 min read 26.4K   3  
This article is intended for those who are working with Visual Studio Team services and have basic understanding of build definition.

Introduction

Visual Studio Team Services (VSTS) is the online team foundation server hosted in cloud. It helps to manage, build and deploy code in the cloud. Using VSTS build definition, we can automate the process of creating a build. A build definition contains all the steps that a build is supposed to do. It also specifies when a build should be triggered. You can trigger the build whenever a check-in is performed by a developer or you can schedule the build to get triggered at a specific time. There is another way to trigger a build which is called “Gated Check-in”. Gated check-in helps to restrict developers from checking in a broken code into source control system and thus helps to avoid blocking your team. With gated check-in when a check-in is initiated by a developer, it will build the project and will check-in the code only if the build is successful. Gated check-in is suitable for projects whose overall build time is less than few minutes.

Enable Gated Check-in Using VSTS Build Definition

To create a build definition, navigate to “Build & Release” tab of VSTS team project and click on “Builds”. Under Build Definitions, click on New button, it will display a wizard to create a new build definition. Select the required template and configure the required repository settings. The build definition has different tabs to configure the build settings. To enable gated check-in, navigate to Triggers tab as shown in the below screenshot.

Image 1

Under Gated Check-in section, click on the check box to enable gated check in as shown in the below screenshot.

Image 2

Save the build definition. Now when a developer tries to check-in code in Visual Studio, gated check-in build is triggered automatically as shown in the below screenshot.

Image 3

The build server creates a shelveset, merges with the latest code and then compiles the code. If the build is configured to run unit tests, then the unit tests are also executed. Once the build is successful, the code is committed to source control.

There is an option to Bypass validation build and check in changes directly. This checkbox is enabled only when the user has “Override Check-in Validation by Build” permission set for the selected build definition.

If "Preserve my pending changes locally" option is checked, then the changes being submitted will remain in the workspace.

How to Set Permission for Build Definition

To enable “Override Check-in Validation by Build” permission, select the build definition in VSTS and click on security as shown in the below screenshot.

Image 4

Set the required option for “Override check-in validation by build” field as shown in the below screenshot:

Image 5

Note

Gated Check-in option is available only for TFVC source control repository. You need to configure branch policies for Git repositories as shown in the below screenshot.

Image 6

Conclusion

I hope this article will help you to configure gated check-in VSTS and you can restrict developers from checking in a broken code into the source control system.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
-- There are no messages in this forum --