Best practices for connecting a repository to CloudBees Feature Management Configuration as Code

Last Reviewed:2026-10-19()
2 minute readKnowledge base

Overview

CloudBees Feature Management Configuration as Code (CasC) synchronizes flags, flag configurations, custom properties, and target groups between the CloudBees Unify UI and a .cloudbees/casc/feature-management/ folder in a connected Git repository. This synchronization is bidirectional, but the initial sync when a repository is first connected is not a merge: CloudBees Unify inspects the state of the application (in the UI) and the repository (branch and .cloudbees folder) at connection time, then makes one side match the other.

Connecting a repository in the wrong order can permanently delete flags, custom properties, and other elements, in CloudBees Feature Management, with no merge or confirmation prompt. This article describes the data-loss scenarios observed and the recommended order of operations to avoid them.

Recommendations

Connect an empty application to a repository that already has a main branch

Connect an application that has no flags, custom properties, or other elements configured in the UI to a repository that already contains a main branch but does not yet contain a .cloudbees folder.

Why this matters:

  • CloudBees Unify creates the .cloudbees folder (and required subfolders) in the repository automatically and commits it.

  • Elements that already exist in the UI, if any, are written into the new .cloudbees folder as files.

After the folder is created, add or edit flags, custom properties, and other elements directly in the repository’s .cloudbees folder. These changes sync to the UI automatically.

Do not create the main branch on a connected repository that already has elements in the UI

If a repository without a main branch is connected to an application that already has flags, custom properties, or other elements configured in the UI, do not create the main branch in that repository while the connection is active.

Creating main on a repository that is already connected to an application with existing UI elements does not create a .cloudbees folder automatically. Instead, CloudBees Unify treats the (empty) repository as the source of truth and deletes all flags, custom properties, and other elements from the UI.

If the application already has elements configured in the UI, create and populate the main branch before connecting the repository to the application.

Implementation

To connect a repository to CloudBees Feature Management CasC without losing data:

  1. Confirm the target repository has a main branch.

  2. Confirm the target repository’s main branch does not yet contain a .cloudbees folder, unless its contents already match the elements configured in the application. Please refer to article_name for further details regarding this particular use case.

  3. Connect the repository to the application.

  4. Verify that CloudBees Unify commits a new .cloudbees folder to the repository, or that existing UI elements now appear as files under .cloudbees/casc/feature-management/.

  5. Make further changes to flags, custom properties, and other elements directly in the repository, or in the CloudBees Unify UI. Both directions sync automatically after the initial connection.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.