Search code examples
visual-studio-2015tfs-2015policycheckin

Check-in policy is not being applied to the TFS 2015


I would like to prevent users for checking in in case the code they want to check doesn't getting compiled.

I added a Builds policy in the settings -> Team Project -> Source Control -> Check-in Policy tab.

enter image description here

This doesn't work, I am able to check-in a code that doesn't get compiled.

What is the way to add a such policy to the TFS?


Solution

  • The Builds policy has a bit of a strange name for what it does. It doesn't check whether your code builds locally, it goes to the TFS server and checks whether there is a CI or gated build configured that would trigger for the proposed code changes. If there is one, it checks if the last build was successful. If not, it prevents adding more code changes that will likely not build.

    This allows teams to check in a specific code change that will cause the build on the server to succeed. The developer submitting these changes uses the "by-pass policy" option to force his changes through to the server. If the build then succeeds, other developers can check in their changes normally again.

    If this protection were not in place, developers could queue hours worth of builds that will all fail, wasting precious time to get feedback and possibly making it only harder to fix the broken build.

    If you do not have a CI or gated build configured, this policy will not seem to do anything, as it will allow you to submit your changes without prompting.

    As far as I can tell there is no policy which will require your local build to be successful.