TFS not honoring /author argument with gated build - tfs

We'd like to have a process like the following:
User submits code review with shelveset of changes they want to be in master branch.
If code passes review, select group of users can pull down the shelveset, and merge the changes into master using the original authors name for historical tracking.
I can use the tf checkin /author:{OriginalAuthor} command, but this doesn't work with our gated build. If I bypass the gated build, it will check in on the original authors behalf, but using the gated build it seems to pull the Author from the shelveset which is still marked as coming from my account/workspace and not the /author.
So I'm wondering, is there a way to have the gated build honor the /author argument for the final check-in that it performs?

I just tested in TFS 2015.3, and enable a Gated Check-in in new build system.
If I use tf checkin /author:A, I'll get a shelveset with message below:
Your check-in has been placed into shelveset
Gated_2016-10-27_01.53.28.8457;B and submitted for validation by build
definition \ScrumProject\Visual Studio.
Once user B request a review, user A re-run command tf checkin /author:A, you'll see the message below, and the change has been checked in by user A.

Related

TFS (Builds-Triggers) - There is impact of checking CI option and Gated Check-in option?

I don't understand why can I check this two options together because this options are not similar in their behavior.
I only want to check in the changes when the build (CI) succeeds.
What I need to do?
Have a nice day.
There is no impact between CI and Gated check-in. When you select CI, it will build whenever someone checks in code, it happens after the changes have been checked in to TFS. If you select Gated check-in, it will accept check-ins only if the submitted changes merge and build successfully, which means only the build succeeded the changes can be checked in.
By default, CI builds are not run after the gated check-in process is complete and the changes are checked in. However, if you do want CI builds to run after a gated check-in, select the Run CI triggers for committed changes check box.
Detailed information you can refer to the link below:
https://learn.microsoft.com/en-us/vsts/pipelines/build/triggers?view=vsts
Since you only want to check in the changes that builds succeed, you
should only select Gated check-in.

tfs 2015 gated check in failed

I created a ci build in tfs 2015.3. On the trigger tab I set gated check in.
Is there a way to let the developer now in vs that the build failed. Currently there is no way, I do not want to use alerts, I would like for a message in vs.
In addition, when the build fails, the files are checked out on the build server, how can I cancel this behavior, this requires a tfs admin to release the files.
In TFS 2013 there used to be a tool called Team Foundation Build Notification that shipped with Visual Studio 2013. However this is no longer the case.
If you don't want to use e-mail notifications there are third party applications that you can run in your tray to receive build notifications. I have used catlight myself recently for the exact same problem. If you are using a chat application like Slack you can also integrate build notifications into your team's slack channel to be notified on build failure.
To answer the second part of your question it is important to understand what a gated check-in does exactly.
When you check-in and a gated check-in is triggerd your files are not checked in but TFS creates a shelveset instead. TFS will then perform a private build using the latest version of the sources in combination with the shelveset it just created. Only when the this private build passes the pending changes in your shelveset will be checked in by the build on behalf of the user who triggerd the gated check-in. This will create a new changeset.
Upon check-in all locks will be released so all files that have a check-in or check-out lock will be released when the build server checks in your changes on behalf of you.
When the build fails no the changes in the shelveset (created when the gated check-in build was triggerd) will not be checked-in by the build server thus the locks will not be released. In the source control explorer the files will still have pending changes (and be checked-out) because the changes in your workspace have not yet been checked-in. This is the intended beheaviour and should not cause any issues for you unless you have disabled multiple check-out and you are, by having these files checked-out, blocking other developers from making changes.
I would not advise you to use a gated check-in when also not allowing multiple check-outs. Furthermore I would not advise disallowing multiple check-outs if it can be avoided in any way.
A gated check-in is meant to safeguard the repository from receiving check-ins that would break the application (it no longer compiles or unit tests fail) or diminish the quality below your standards. However this also means you cannot check-in until all the rules and validations you have in your build process pass and thus means other developers will be locked out until you are able to get past the "gate".

Don't Alert when Gated Checkin Fails

We have a team alert in TFS 2015 that sends an email out to all developers whenever one of our builds fails.
I'd like to modify it to not issue emails when someone fails a private build, or a private gated check-in fails (we don't use gated check-ins by default). In these cases, a separate alert will issue to just the individual developer.
Below is the current criteria
However, when I tried to run a manual gated check-in just now, the build failure issued an email to the entire team.
What additional conditions are required to ensure that these emails are not generated when I create a build using a shelveset - whether or not I choose to automatically commit the changes on success.
There is no private gated check-in build, "gated check-in build" is not Private build.
You queue a private build if you want to build the changes that you
have put into a shelveset.
More detail info with private build in TFS, please refer this MSDN link:
Queue a build
When you are going to use the private build and not issue emails when someone fails, you can add a build reason not contain check in shelvest as a workaroud.
The part above your screen shot is the part that identifies if the alert is being configured for a Team (sends to everyone) or a personal alert (just to you).

Allow certain users to by-pass the gated check-in on TFS

I want to enable the gated check-in trigger for my TFS Build but also want to have a way to specify users who can commit their code directly without waiting to TFS to verify their code changes.
If you edit the "Security" of the build definition:
There is a permission you can control called "Override check-in validation by build" (or similar, I don't have TFS 2012 to hand, I'm using VSTS for the screen shots).
Grant certain people this permission and they can bypass the validation.
When they check-in code they will get the usual Gated Build prompt, but under "Show Options" there is a checkbox to bypass the validation:
By default Project Administrators and upwards have this permission.
For TFS 2015 Right click on the build definition, select security.Then change Override check-in validation by build to Allow

TFS 2010 Checkin Shelveset with merge conflicts

I have a gated checkin build which does change some files of the changeset which is provided by the user requesting the build. The build does mainly set the build version number in the source files for all targets.
The gated checkin activity does checkin the shelveset of the user. Now I want to checkin also the changed files by my build which can potentialy conflict with files part of the users shelvset. This results in merge conflicts.
Is use VersionControlServer.CheckinShelveset which has no options to force a checkin in case of merge conflicts due to the other checkin of the previous shelveset. I tried to change the shelveset provided by the user but I cannot change a shelveset which was not created by the same user. I am forced therefore to create a second shelveset and wait until the gated checkin activity which lives on the build controler has succeeded.
When I have a workspace I could resolve the changes but on the build controler there is no workspace (it is on the build agent) so I would have to create a new workspace, unshelve the shelveset of the other user and try to merge my other shelveset into this one and then try to checkin which is not easy and more seriously it would take quite some time.
Is there a way to checkin a shelveset in and force TFS to simply overwrite the latest version without having a workspace? Or is there another way to get my changes of the build checked in without merge conflicts? If I would check earlier on the build agent then the gated checin will fail with merge conflicts on the build controler.
If you have your code that does this run on the build agent rather than the controller, you would have access to the workspace. In that case, you could consider having two checkins: the first is the user's changes, and the second would be the modifications your code made. Or, you could simply make the changes to the code and then do the checkin from the workspace of the build agent. In that case, the shelveset submitted by the user would not be used for the checkin but as the basis for your code to make further changes and then check that in.
There's no way to force a shelveset to be checked in despite conflicts.

Resources