# Is it possible to set a repository's default branch dynamically?

**URL:** https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028
**Category:** Feature Requests
**Created:** [April 22, 2021, 11:19am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028 "2021-04-22T11:19:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ktopaz](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ktopaz/32/2390_2.png) [@ktopaz](https://www.finalbuilder.com/forums/u/ktopaz)
#### Post date: [April 22, 2021, 11:19am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/1 "2021-04-22T11:19:35Z")

</div>

Hi Guys,

We’ve started enforcing a code freeze policy using Continua CI configuration conditions:  
It works perfectly (The system discards any builds which do use the dynamically pre-determined code freeze git branch during specific days of the week (unless a team leader is performing the build, in that case it is allowed).

I would also like to set the default branch to this code freeze branch but only during certain days.  
I couldn’t find a way to dynamically update the default branch on a Continua CI configuration or on a Continua CI repository object - is this at all possible somehow?

Thanks!

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [April 22, 2021, 11:35pm UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/2 "2021-04-22T23:35:37Z")

</div>

Hi Arik,

Unfortunately, this is not currently possible. I guess what you are looking for could be achieved at the configuration level by adding time interval sections to the Configuration Repository Branch Mappings dialog, but this would not be a small task and it’s not something that we can prioritise at the moment.

---

<div class="post-metadata">

### Author: ![ktopaz](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ktopaz/32/2390_2.png) [@ktopaz](https://www.finalbuilder.com/forums/u/ktopaz)
#### Post date: [October 20, 2022, 10:43am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/3 "2022-10-20T10:43:32Z")

</div>

Hi Guys,  
Just wanted to ask if this is somehow more feasible at this time?

I see there’s a server property called “Server.Repository.PollingFrequencyInSeconds.Default”  
How about adding a similar: “Server.Repository.MySpecificRepoName.DefaultBranch” property?  
If somehow I can populate such a server property value with an expression - I’d be able to set it dynamically using our own logic.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [October 20, 2022, 11:19am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/4 "2022-10-20T11:19:35Z")

</div>

Hi Arik,

Server properties can not be set dynamically except by property collectors, but variables can be set dynamically during a build using the Persist Build Variable event handler.

I am right that you are using Git? Do you want to be able to change the default repository branch for a specific configuration or globally for all associated configurations? If the latter, then would allowing query expressions and variables to be entered in the Default Branch field of Git repositories work for you?

---

<div class="post-metadata">

### Author: ![ktopaz](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ktopaz/32/2390_2.png) [@ktopaz](https://www.finalbuilder.com/forums/u/ktopaz)
#### Post date: [October 20, 2022, 11:33am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/5 "2022-10-20T11:33:51Z")

</div>

Thanks Dave!

Correct, we’re using Git, and our scenario is the latter (global scope repository that is used by many configurations and we would like to set the default branch on it dynamically so all configurations using it will have the same default branch).  
So - the solution you suggested could work perfectly for us, if we are able to set the variable/query expression dynamically by running something that modifies that value - that would be just great!

Would that be something that you’d consider adding soon?

Thanks again!

---

<div class="post-metadata">

### Author: ![ktopaz](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ktopaz/32/2390_2.png) [@ktopaz](https://www.finalbuilder.com/forums/u/ktopaz)
#### Post date: [November 23, 2022, 12:50pm UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/6 "2022-11-23T12:50:29Z")

</div>

just bumping this to ask if this is still planned for any future version?

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [November 23, 2022, 10:37pm UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/7 "2022-11-23T22:37:38Z")

</div>

Hi Arik,

We’ve looked into what is required to implement this and there’s quite a lot areas of the code which are affected, so it’s not a quick task.

We still plan to do this, although we’re currently thinking that we will allow expressions at the configuration-level rather than the global level, e.g. for the Default Branch field of the Configuration Repository Branch Mappings.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [December 8, 2022, 8:49am UTC](https://www.finalbuilder.com/forums/t/is-it-possible-to-set-a-repositorys-default-branch-dynamically/7028/8 "2022-12-08T08:49:11Z")

</div>

Hi Arik,

This feature has been implemented in [v1.9.2.1046](https://www.finalbuilder.com/downloads/continuaci/continua-ci-version-history-v192).
