Restricting TFS check-in policy to specific users
Asked Answered
A

2

7

The title says it all really. Our team wants to somehow restrict a TFS check-in policy to some select users.

We are currently using something similar, but to restrict server paths. We have a Custom Path Policy policy attached to a Work Items policy in our project, and it is working as expected. I wondered if it would be reasonable to create another policy like that, that scopes a certain other policy to a group of predefined users.

We would like to use a feature like that with this code review policy, to enforce that code reviews are requested before check-in for the new developers that enter the company, but not for everyone.

Amylum answered 19/9, 2013 at 16:40 Comment(2)
thanks for question, i've looked for the same codereview per developer group policy but failed. Have you found a solution?Pelagia
@Pelagia Not really. Since then I've mostly migrated from TFS so I ended up not following this. Would love to know though.Amylum
P
1

Here is my custom policy implementation. It allows to run child policy if user does not have certain permissions (is not member of certain group).

It can be used with custom path policy from TFS power pack and ColinsALMCornerCheckinPolicies Then it will be possible to ask for code review only for certain projects|files|folders and only if user has no permission to check-in without code review.

https://github.com/oleksabor/GroupMembershipPolicy

You have said that had migrated from TFS but I'd like to leave answer here because have not found solution for original question.

Pelagia answered 14/2, 2017 at 10:54 Comment(1)
Absolutely amazing. I'm marking your answer as the correct answer for now, but unfortunately won't be able to test your solution. It does sound quite good though using the child rule strategy: it will allow folks to apply it on top of any existing rule, working like a decorator. I'm sure it will come in handy for someone so I really appreciate you taking the time to post it here.Amylum
P
1

There is no way to do this out-of-the-box, but you could indeed use the same process as the Custom Path Policy. You'd need to create and distribute a custom checkin policy to all your team members. Try using a tool like Reflector or dotPeek to inspect the Custom path Policy.

Then create your own Custom User Policy, it's a pretty simple class to implement, the core is the Evaluate method which would be almost a duplicate of the same method in the Custom path Policy. You can pop-up a simple custom windows forms dialog to show a List of users that this policy applies to (I'd personally create an option to use Blacklists as well as Whitelists).

By default you can find the custompathpolicy defined in this assembly:

C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\Check-in Policy Pack\Microsoft.TeamFoundation.PowerTools.CheckinPolicies.CustomPathPolicy.dll

Prettypretty answered 31/1, 2014 at 11:14 Comment(0)
P
1

Here is my custom policy implementation. It allows to run child policy if user does not have certain permissions (is not member of certain group).

It can be used with custom path policy from TFS power pack and ColinsALMCornerCheckinPolicies Then it will be possible to ask for code review only for certain projects|files|folders and only if user has no permission to check-in without code review.

https://github.com/oleksabor/GroupMembershipPolicy

You have said that had migrated from TFS but I'd like to leave answer here because have not found solution for original question.

Pelagia answered 14/2, 2017 at 10:54 Comment(1)
Absolutely amazing. I'm marking your answer as the correct answer for now, but unfortunately won't be able to test your solution. It does sound quite good though using the child rule strategy: it will allow folks to apply it on top of any existing rule, working like a decorator. I'm sure it will come in handy for someone so I really appreciate you taking the time to post it here.Amylum

© 2022 - 2024 — McMap. All rights reserved.