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: 

 
Test connection failed in build C
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:

Failed to start build #1.0.421 in branch hotfix/test_test_test at 22 Jan 19 14:14 on <build agent name>
"Failed to collect changes, error: Cannot find revision of the default branch 'refs/tags/1.0.1' of vcs root '<VCS root name>'"
 
 
VCS problem: <VCS root name>
Failed for the root '"<VCS root name>" {instance id=4053, parent internal id=1079, parent id=<build ID>, description: "git@<repo URL>.git#refs/tags/1.0.1"}: Cannot find revision of the default branch 'refs/tags/1.0.1' of vcs root '<VCS root name>' 
 
 
When I disable "Allow builds in the default branch" and run the C's custom build against a specific branch (say "hotfix/test_test_test") TeamCity complains about not being able to checkout the default branch:
 
"Failed to collect changes, error: Builds in default branch are disabled in build configuration"
 
Is that possible for TeamCity to pick up the default branch dynamically with every build configuration using dependency parameters, check it out and tag it after build finishes?
0
5 comments

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?

 

0
Avatar
Permanently deleted user

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.

0

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.

0
Avatar
Permanently deleted user

Hello,

I had one project to trigger the builds for every check-in for all branches,

Project-1

  • Triggers build for all branches
  • Trigger for each check in
  • In VCS

             Default branch -> refs/head/master            

             Branch Specification: +:refs/changes/*

  • In Triggers

            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)

  • In VCS

             Default branch -> refs/head/New-xyz            

             Branch Specification: +:refs/changes/New-xyz

  • In Triggers

            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

0

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?

0

Please sign in to leave a comment.