To Trigger the build for specific branch and avoid trigger from other branches.

Hello,

I had one project to trigger the builds for every checkin 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,

 

0
6 comments
Avatar
Permanently deleted user

Anybody here..?

0

Hi,

 

In Project 1, your trigger branch filter is +:*, so everything will be triggered, independently of what is in 2. You'll need to exclude explicitly -:Nex-xyz if you want it not to trigger. Alternatively, you can use a parameter in the branch specification, and then have different branch specifications per project defined in the project parameters, even with a shared VCS Root.

 

As you have defined the branches like "refs/heads/New-xyz", the branch name is the full content. If you would like the branch name to be only "new-xyz" you should put it into the branch specification and put it into parenthesis. It's not required on Project 1 because the "*" converts the branch name into what is matched by the *. In the branch filter for the trigger on project 2 either add the full name or put the parenthesis on the branch name, otherwise refs/heads/New-xyz and New-xyz are at that point not matching each other.

 

I think that fixing this small issues should fix the triggering on both, could you give it a try?

0
Avatar
Permanently deleted user

Hi Denis,

Thanks for the reply.

I tried for explicityly excluding the a branch from trigger in Project-1 as below. Still the branch build is triggered on Project-1

 

Project-1

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

             Default branch -> refs/head/master

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

 

 

  • In Triggers

            per -checkin Triggering both the options are selected

            Quiet period: 60 seconds

            Branch Filter: -:New-xyz
                                  +:*

Thanks,

0

Hi,

 

Thanks for the follow up. I'd recommend checking exactly which branch name is displayed as being triggered, and adding exactly that string to the "-:" line on the branch specification. Adding it to the trigger exclusion does nothing if the branch name isn't properly set, which is what adds it to the specification in the first place.

 

If that still doesn't work, please use the submit a request button on top and send with it the following:

-A screenshot of the exact configuration for the branch specification

-A screenshot with the build history, showing builds on the branch with the branch name on it.

 

The core root of the issue is that TeamCity is not excluding the branch from the branch specification, which means that your branch name is not being matched by the exclusion rules. If you set the exact string it should work. There might be issues with strange characters but other than that this is one of the best tested parts of it, as it's fundamental for TeamCity's core functioning, so there has to be something wrong in the configuration.

0
Avatar
Permanently deleted user

Hi,

 

I received the below information from the vendor, letting me know that above configuration will not work. 

"MasterReviewProject1 " VCS root is configured to build branch "refs/heads/master" and also all the branches which start with "refs/changes" except for "refs/changes/New-xyz"
"MasterReviewProject2 " VCS root is configured to build branch "refs/heads/New-xyz" and "refs/changes/New-xyz"

Now in the build configuration with the first VCS root, a build is triggered on branch "refs/changes/52/2532/1" which is perfectly along the lines with the configuration (the branch name starts with "refs/changes" and does not equal "refs/changes/New-xyz").

What you might mean is that "refs/changes/52/2532/1" branch is meant to be merged into "refs/changes/New-xyz ", but that knowledge is not stored in Git which TeamCity integrates with so there is no way for TeamCity to know that. If this is indeed what you mean, then you probably use some system which stores some branch metadata.
At this time TeamCity integrates on that level only with GitHub, so I am afraid there is no way to configure that workflow in TeamCity without extra effort and usage of an external system.

 

I am still wondering, TeamCity can provide configuration option - branch specification why not it supports for my use case.

 

Any inputs on this?

 

Thanks,

Naveen

0

Hi Naveen,

 

yes, I do have some input. The conversation with the vendor was forwarded to one of our other support channels and I've been able to examine the screenshots. I'll not leak names but will point out what I consider to be the most likely causes of the issues.

 

From the screenshots we see, Project 1 was triggered when you wanted Project 2, but, Project 1 has 60+ changes committed to it, in a trigger that has the default quiet period of 1 minute, and is being built on a branch that is not New-xyz (52/2532/1 instead). This is perfectly in unison with the configuration set up. The only situation this would be an issue would be if the 60+ changes were all of them in the branch you were pushing to.

 

With 60+ changes pending, it seems to me like the most likely result is that there were changes to that 52/... branch that got that build to trigger as well. With a single change being pushed to that branch along the New-xyz, that would be enough for that configuration to trigger. You can check this information if you see this situation by requesting the teamcity-vcs.log and filtering for your VCS Root, seeing what teamcity has picked up as changes collected from the repository, which eventually have triggered the branches.

0

Please sign in to leave a comment.