VCS Trigger branch filter ignored
I have the following VCS Root definition
object MyCli : GitVcsRoot({
name = "my-cli"
url = "git@gitlab.internal:path/to/my-cli.git"
branch = "main"
branchSpec = "+:refs/heads/(*)"
authMethod = uploadedKey {
uploadedKey = "my key"
}
})
Then build types are setup as:
object BuildAndPublish : BuildType({
name = "Build and Publish"
...
vcs {
root(MyCli)
branchFilter = "+:<default>"
}
steps {
script {
...
}
}
triggers {
vcs {
branchFilter = "+:<default>"
}
}
...
})
object LintAndTest : BuildType({
name = "Lint and Test"
...
vcs {
root(MyCli)
branchFilter = "-:<default>"
}
steps {
script {
...
}
}
triggers {
vcs {
branchFilter = "-:<default>"
}
}
...
})
Yet, the build still triggers on every branch - and fails immediately for being unable to clone as the non-default branch is not part of VCS Root branch filter
Failed to collect changes, error: Builds in SOME_BRANCH branch are disabled in build configuration My CLI / Build and Publish
Guidance appreciated!
Please sign in to leave a comment.
Now clear from https://teamcity-support.jetbrains.com/hc/en-us/community/posts/20174106834578-Gitlab-integration-notify-multiple-build-types
As the integration adds a build to the queue, the build is not “trigger by VCS changes”. The trigger, and its configuration, is ignored (and not even required).
Changing to webhook will perform as expected
Hi,
The settings below do what you describe. BuildDevelop is triggered only on non-default branches, and BuildMain is only on default. Please check.
Hi Anton Vakhtel thanks for the hint!
It wasn't triggering mostly because of the update I shared (using “integration” instead of “webhook”, so there was no Vcs change).
But I've also updated as you mention, it's cleaner.
One thing that is confusing to me however is the delay between Vcs Root getting “Pending Changes” and the build actually triggering.
Most of the times it's 1min but sometimes it's like 2min.
This pops up almost instantly after I “git push” to the branch, but the build is only queued 1 to 2min later, not always the same.
Is it some “quiet” period that can be configured somewhere?
The VCS trigger has a quiet period setting: https://www.jetbrains.com/help/teamcity/2024.03/configuring-vcs-triggers.html?Configuring+VCS+Triggers#Quiet+Period+Settings. However, the settings you provided seem to indicate that it is disabled.
Can you change the polling interval in the VCS root settings and see if it will have an effect? As mentioned in the documentation for the quiet period, the actual quiet period will not be less than the maximum checking for changes interval among the VCS roots of a build configuration.
Best regards,
Anton
Hi Anton, thanks for the hint.
Yes, quiet period is disabled for this Vcs Root.
“the actual quiet period will not be less than the maximum checking for changes interval”
I had read this part but I couldn't find anything with that wording in the UI.
It refers to the polling interval? It's set to use “default” which is 300 seconds in my case, but whenever the commit hook is triggered/detected, it changes the checking interval to 4h.
I'm not sure I can set less than 60s for polling in this server, but I'll test it…
Please note that even if you set it lower than 60 seconds, it doesn't mean that it will poll with this interval, as commit hooks change the polling behavior. If this setting has no effect on the queue timing for the commit hook configuration, then I guess there could be some default quiet period for commit hooks, which I am confirming right now.
Best regards,
Anton
I changed it to 30s and it didn't change the behavior.
Anyway, it was more of a curiosity as with Jenkins I would get instant build by disabled quiet period.
I can always revert to using jetbrain integration with a no-op build type just to add other build types as dependencies. That would trigger them instantly, but it looks uglier to maintain.
I'll survive with the 1min cooldown, thanks for the help
If you'd like, we can try to figure the cause of the delay, for this, please reproduce the behavior and share the teamcity-vcs, teamcity-triggers and teamcity-server log files, I will see what I can find. You can upload them to https://uploads.jetbrains.com/ and share the upload ID.
Best regards,
Anton
Hi Anton, I think it's acceptable even though it'd be interesting to understand if it could be fixed yes.
But I'll have to find the time to try to reproduce in a local container first using only demo projects as I'm not an admin of the current instance I'm using to provide all those details.
I'll update this once I managed to do it
I had to setup a local teamcity for another issue so decided to give this a try as well
I used github as VCS: https://github.com/fopinappb/teamcity-integration-test/ and ngrok tunnel on top of teamcity docker to be reachable.
This actually gave me visibility on the time of the request from github webhook to compare with the rest
Relevant logs:
NGROK:
VISUAL PERCEPTION:
two seconds or so before VCS shows that it has been triggered via commit hook and shows pending changes. Build does not immediately start
TEAMCITY SERVER LOG (-1 timezone compared to workstation):
The only thing that it logs is when the build is added to queue. It didn't log anything about the VCS hook being called.
Took 23 seconds to add build to queue
TEAMCITY AGENT LOG:
5 seconds and agent picks up the build
Project / Build config
Almost half of the delay you see should be attributed to the fact that triggers are fired up every 10 seconds.
Other than that, there are really no defined factors that may affect the delay, but it could be attributed to database and data directory operations, as well as other inner workings of TeamCity.
I hope this clears up the concerns you have.
Best regards,
Anton
It does, thanks Anton.
If I really want it instant, I'll switch over to use the integration again and snapshot dependencies.
Though there I'll lose the “vcs trigger filters”, there'll probably be workarounds.
Cheers