hashbytes
hashbytes

Reputation: 799

VSTS should not trigger merg/commit build, NO_CI

When a dev opens a PR targeting a branch, we have a trigger to run a build

We are making a commit from build server (as part of the build process) to the PR source branch with commit message as something ***NO_CI*** thinking that this will not trigger another build for this commit. But, it still triggers a build

Any flaw in my approach or Any other way we can stop it not to trigger a build for this commit.

Do we have to enable any setting on VSTS to make***NO_CI*** to work?

Upvotes: 0

Views: 310

Answers (2)

jessehouwing
jessehouwing

Reputation: 114651

First off, pushing changes to a branch being monitored by a build definition, especially if it's to the same folder is a pretty bad idea. Always has been. I know, since I built the TFVC tasks to allow people to keep doing this madness in order for them to migrate to the new build system.

The ***NO_CI*** magic comment works with TFVC, but doesn't work with Git. With Git and the new build system you can use branch filters to prevent the build from triggering on certain branches and you can setup path filters to exclude certain paths from triggering the build again. (In most cases people tend to commit assemblyinfo.cs files; by excluding these from triggering the build you can safely do so).

It's pretty dangerous to commit files during the build, the repository is checked out in detached head state and your commits might hit changes to the target branch in-flight. Instead consider pushing your changes to another branch instead.

Upvotes: 0

Daniel Mann
Daniel Mann

Reputation: 59020

Add the CI build to your branch policy -- that will trigger the build when a PR is opened.

Add a CI filter for refs/pulls/* on the build definition. That will prevent a double-build from happening.

Once the PR is completed, the CI build for the merge will run normally, as it should.

Upvotes: 1

Related Questions