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

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!

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.

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.

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?

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!

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

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.

1 Like