Dynamic VCS root default branch with every new build using dependency parameters
I've got a build configuration C which is supposed to pick up the build id of the build configuration B that it depends on, checkout the git commit with this build id and tag it after the C succeeds.
C has both snapshot and artifact (build from the same chain) dependencies upon B, which doesn't have VCS root attached, but picks up branches from some other build configuration A.
VCS root is used only by build configuration C.
In VCS settings "Allow builds in the default branch" option is enabled.
C's VCS root default branch is defined as "refs/tags/%dep.<id_of_B>.build.number%".
C's branch specification: +:refs/tags/(%dep.<id_of_B>.build.number%)
When I click "Test connection" button in the "Edit VCS Root" settings it results in the following error:
Cannot find revision of the default branch 'refs/tags/1.0.1' of vcs root 'jetbrains.git'
When I save the setting anyway and try running the build C for a specific branch (C's custom build -> Changes -> Build branch -> <specify the hotfix branch that was previously run on B> -> Run Build) it results in the following errors displayed next to build configuration names:
Please sign in to leave a comment.
It should be perfectly possible to get the branch dynamically, as demonstrated by the fact that the error is displaying that it gets resolved, but it cannot find revisions.
Does the tag "1.0.1" exist? Is it built in TeamCity?
The problem is that the dependency build number is not "1.0.1" (it's say "1.0.123") and the build configuration seems not to be picking up the %dep.<id_of_B>.build.number% parameter properly, it seems it defaults to "1.0.1". The B's "1.0.123" build is successful.
Hi Maciej,
sorry for the delay in answering. I've been asking internally because this issue was more complex than it seemed in the surface, and I have missed some important point. The issue is that TeamCity resolves this parameters before the first build is even run, which eventually leads to the values being taken from the default, because the dependency hasn't run for them to be resolved.
But on a deeper inspection, we'd like to ask a few questions about the intention:
-If your intention is to tag something on the initial build, then use those same sources, this change isn't necessary. TeamCity will automatically use the same revision in different builds of the same chain if the VCS Root is shared. The default branch is expected to be used on default settings. If this is going to be changing on every run of its dependencies, it loses its main utililty.
-If your intention is to create new commits and then tag those, then the best option is to remove automatic checkout and run manual checkout instead. TeamCity, as mentioned above, will maintain consistency on the commits, and will gather the commits to run the full build chain when the first build of the chain is started.
-If you want to pick up a branch from elsewhere but don't need to check out the changes, you can disable checking out automatically, again, and it will have all of its functionality available.
Hope this helps.
Hello,
I had one project to trigger the builds for every check-in for all branches,
Project-1
Default branch -> refs/head/master
Branch Specification: +:refs/changes/*
per -checkin Triggering both the options are selected
Quiet period: 60 seconds
Branch Filter: +:*This settings works fine for all branches.
----------------------------------------------------------------------------------------
Project 2
I have created a new project for specific branch (New-xyz)
Default branch -> refs/head/New-xyz
Branch Specification: +:refs/changes/New-xyz
per -checkin Triggering both the options are selected
Quiet period: 60 seconds
Branch Filter: -:*
+:New-xyz
------------------------------------------------------
Now with these two projects, the builds gets triggered on both. This is the issue.
I want to trigger the builds on Project 1 for all branches except for New-xyz branch and I want to trigger the builds on Project 2 only for branch New-xyzand not for other branches.
How do I do the settings if it has to work for above scenarios. Appreciate your valuable feedback and solution.
Thanks,
Naveen
Hi Naveen,
I'm not sure whether this is a mistake, but we had this discussion already here: https://teamcity-support.jetbrains.com/hc/en-us/community/posts/360003434040-To-Trigger-the-build-for-specific-branch-and-avoid-trigger-from-other-branches- . Did you post this new thread or was this an error on the forums?