Set up configuration as code

4 minute read

This guide walks you through the steps to connect your GitHub repository to CloudBees Unify Feature management and activate configuration as code (CasC).

Before you begin

CloudBees recommends installing the CloudBees Feature management SDK before proceeding to configure CasC.

The CloudBees Unify only accesses files in your repository that contain Feature management code. The CloudBees Unify leverages GitHub Apps to enable secure integration with a GitHub organization and selected repository(s).

Access the CasC integration

To access the CasC integration with feature flags:

  1. Select Feature management  Flags.

  2. Select Application and choose an application.

  3. Select icon Connect your configuration as code (CasC).

    The Connect your configuration as code (CasC) link is visible only if CasC has not been set up previously for the selected application.
CasC connection
Figure 1. Access CasC

The Configuration as code panel displays existing connected repositories, and it allows you to identify the GitHub repository the connection uses.

CasC connection
Figure 2. Set up the CasC connection
  1. Search: Use the Search field to locate previously installed GitHub repositories from the list.

  2. Toggle: Limit the display of GitHub repositories that are installed but not connected to an integration by toggling on or off.

  3. Repositories: Select one of the available GitHub repositories in the list to connect it to the CasC integration.

  4. Connect your repository: Select this link if your GitHub repository is not displayed in the list, to install and activate your GitHub repository.

Activate CasC with GitHub

To activate CasC with GitHub, proceed with one of these methods, depending on your configuration:

Connect to a new repository

If your GitHub repository is not displayed in the list of available repositories, follow the steps below to connect your GitHub repository.

If you are connecting to a new GitHub repository, it must be initialized in GitHub before it can be used. Initialization involves adding at least one file, such as a README, license, or an initial commit. For more information, refer to Quickstart for repositories.
  1. From the Configuration as code panel, select Connect your repository.

  2. Select GitHub App.

  3. Type a name for the integration.

  4. Type a description for the integration.

  5. Select Install GitHub app.

  6. In the GitHub window, select the organization that contains the repository for this connection.

  7. Select the appropriate repository access.

  8. Select Save.

  9. In CloudBees Unify, select Feature management  Flags.

  10. Select icon Connect your configuration as code (CasC).

  11. Select your newly added GitHub repository from the list.

  12. Select Submit.

  13. Refresh your browser.

The link at the top of the Flags window, Connect your configuration as code (CasC) should now display as a link to your GitHub repository.

Use an already integrated repository

To activate CasC with a GitHub repository that you have already integrated with CloudBees Unify:

  1. Select the organization.

  2. Select Feature management  Flags.

  3. Select the link at the top of the window: icon Connect your configuration as code (CasC).

  4. Locate a GitHub app using one of the following methods:

    1. Select Search to locate a previously installed GitHub repository.

    2. Select Toggle to limit the display of repositories that are installed but not connected to an integration.

  5. Select an available repository from the list.

    If your GitHub repository is not displayed in the list, select Connect your repository to install and activate your GitHub repository on CloudBees Unify. Refer to Connect to a new repository for more information.
  6. Select Submit at the bottom of the window.

  7. Refresh your browser to ensure the latest changes are displayed.

The Connect your configuration as code (CasC) link is replaced with a link to your GitHub repository.

Create the CasC YAML files

To configure CasC in the Cloud-native CloudBees Unify, you can create YAML files and folders using one of the following methods:

  • Generate files automatically via the UI

    • Use CloudBees Unify UI to create the entities, such as target groups, or custom properties.

    • The system generates the corresponding YAML files and organizes them under the appropriate folders in the SCM repository.

    • This method provides a structured starting point, making it easy to edit and refine.

  • Manually create files

    • Write YAML files yourself using a text editor or IDE, following the expected folder structure:

      • feature-management/flags: For defining feature flags.

      • feature-management/target-groups: For defining target groups.

      • feature-management/flag-configurations: For flag configurations organized by environment.

    • Save and commit the files to your SCM repository.

  • Copy and edit existing files

    • Use an existing YAML file as a template.

    • Copy the file, adjust parameters such as flag names, conditions, or target groups, and save it in the appropriate folder.

Begin by creating entities in the UI to generate skeleton YAML files. These files can be downloaded or edited directly in your SCM to refine the configuration.

Ensure that all YAML files adhere to the CloudBees Unify CasC folder structure, as only valid files within the specified directories are interpreted by the system.

Verify your setup

After connecting your repository and creating YAML files:

  1. Check that your repository shows the .cloudbees/casc folder structure.

  2. Verify that YAML files appear in the appropriate subfolders.

  3. Confirm that entities created in the UI are reflected in your SCM.

  4. Test that changes made in SCM sync to the CloudBees Unify UI.

Next steps