Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Teamcity showing deleted branches

We're using TeamCity, and I've set up jobs to pull from branches. But when those branches are deleted they still appear in Teamcity:

List of outdated branches, only refs/master is active

(List of outdated branches, but only refs/master is actually active)

The Teamcity documentation actually specifies what constitutes an active branch:

Active branches

In a build configuration with configured branches, the Overview page shows active branches.

A number of parameters define whether a branch is active. The parameters can be changed either in a build configuration (this will affect one build configuration only), project, or in the internal properties (this defines defaults for the entire server). A parameter in the configuration overrides a parameter in the internal properties.

A branch is considered active if:

  • it is present in the VCS repository and has recent commits (i.e. commits with the age less than the value of teamcity.activeVcsBranch.age.days parameter, 7 days by default).
  • or it has recent builds (i.e. builds with the age less than the value of teamcity.activeBuildBranch.age.hours parameter, 24 hours by default).
  • ! A closed VCS branch with builds will still be displayed as active during 24 hours after last build. To remove closed branches from display, set teamcity.activeBuildBranch.age.hours=0.

But... I don't understand their description! :) What do they mean with "parameters in the configuration"? I've tried making parameters in my jobs like so:

Adding parameter teamcity.activeBuildBranch.age.hours

(Adding parameter teamcity.activeBuildBranch.age.hours)

But that doesn't do anything. Maybe I'm exposing myself as a total TC noob, but can anyone guide me through how to correctly alter these settings so I only show repository-active branches in my build jobs?

like image 713
Jon Lauridsen Avatar asked Mar 25 '15 09:03

Jon Lauridsen


People also ask

How do I delete a Teamcity branch?

To remove closed branches from display, set teamcity. activeBuildBranch. age. hours=0 .

What happens when branch is deleted?

In Git, branches are just pointers (references) to commits in a directed acyclic graph (DAG) of commits. This means that deleting a branch removes only references to commits, which might make some commits in the DAG unreachable, thus invisible.

What is the default branch in Teamcity?

The default branch allows using different branches in different VCS roots (for example, if one of the roots is Git and another is Mercurial) and in different builds when they are linked by a snapshot dependency.


2 Answers

I suddenly had success after adding parameters to the project configuration. Before now I've been adding parameters to individual builds and never saw a difference.. Maybe that's just me misunderstanding the obvious.

enter image description here

enter image description here

teamcity.activeBuildBranch.age.hours = 0 teamcity.activeVcsBranch.age.days = 1 

This works in-so-far as the list of active branches is culled. There's still one deleted branch it considers active for reasons I can't yet decipher (history was rewritten several times in it), but at least all others are now inactive.

like image 88
Jon Lauridsen Avatar answered Sep 23 '22 06:09

Jon Lauridsen


I had similar question when we first started using branches in TC.

As I recall the branches will stay visible until the conditions specified expire. It doesn't matter if the branch has been deleted, if it had commits in the last 7 days then it will stay visible for 7 days after the last commit even if it is deleted immediately.

So basically don't worry, they disappear eventually and I think you can lower the teamcity.activeVcsBranch.age.days value if 7 days is too long to wait, but you will then lose branches that have no activity within that time I think.

like image 39
Sam Holder Avatar answered Sep 22 '22 06:09

Sam Holder