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

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.

Related

After upgrading to TFS 2017.3, web portal check ins do not kick off the gated check in build

We upgraded our TFS to 2017.3 last night, and all appears to be working as expected, except when making changes to files in the web portal.
When I click the Check In button, I get the following error:
Your check-in could not be completed because it affects the following gated build definitions. \USA\BuildDefinition To complete your check-in you will need to queue a build of the shelveset Gated_2021-02-05_10.23.14.4571;MyDomain\MyUser.
If I make the same change in visual studio, it kicks off the gated check in fine. Just not through the web portal.
Any ideas why that is?
Please try below steps to re-enable the gated check in.
Navigate to the build pipeline-->Edit-->go to Triggers tab-->Disable Gated check-in -->Save-->Enable Gated check-in-->Save again.
If above disable and re-enable the gated check-in doesnot work. Please try to re-create the build pipeline and configure the 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".

TFS not honoring /author argument with gated build

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.

TFS Continuous integration except certain checkins from triggering build

I have TFS continuous integration set up, where every check-in triggers a build. But I also want some scripts to automatically modify specific files as part of the build process. This causes a cascade of builds, because files modified by scripts cause another build to be queued. How do I enable continuous integration, but except some check-ins from triggering the build?
UPDATE Solution is: put the ***NO_CI*** into comments when checking in.
If you look at the way a Gated Build works it bypasses any configured CI by spending ##NOCI## or something similar to the checkin comment. I would think that you could do the same to bypass.
Switch to a Gated Build for one build and see the created comment tag.

Customize TFS gated check-in message suffix ***NO_CI***

TFS build templates have the NoCIOption property that drives whether all gated check-in messages have ***NO_CI*** appended. This in turn optimizes away the daily continuous integration (CI) build if all the check-ins since the last CI build have been gated ones.
However, in my environment, the set of tests run during a gated check-in is much smaller than the set of tests run during a CI build, to achieve reasonable gated check-in latency, and we therefore want to run the CI build even if there have been only gated check-ins since the last CI build; this makes the prominent "NO_CI" marker as it stands quite confusing.
Furthermore, it would be nice if we had some kind of direct reference from the commit message to its respective gated check-in build number, for example from code history.
Is it possible to customize the commit message during gated check-in, so as to include the build number in it?
I have been looking at SyncWorkspace properties but saw nothing obvious.
At the moment we don't have a way to customize the commit message at this time. If you want the CI build to run after the gated checkin then you simply need to set the NoCIOption to False a CI build will be triggered after the check-in.
I don't think it is possible to get the NO CI message into a gated builds check in. Maybe you could consider using a Scheduled Build instead of a CI build to ensure your larger test set gets executed regularly.
Is it possible to customize the commit message during gated check-in, so as to include the build number in it?
No, this would not be possible. The build number is generated as part of the build script's execution; in order to display it at the point of checkin you would have to wait for the build to have started, which it may not always do immediately (e.g. if your server has to queue the build).

Resources