Code Studio

Configuring repository mirroring in Code Studio

Repository mirroring is a feature in Code Studio. With this feature, you can synchronize your Code Studio git repository with an external repository managed by another git provider.

Similar to any mirroring activity, a repository can be mirrored in two directions:

Note

Currently, Code Studio only supports mirroring out to another git repository. However, it is possible to facilitate the process of mirroring another repository into Code Studio using an existing, non-Code Studio CI/CD solution.

Mirroring Code Studio out to another repository

This method of mirroring Code Studio out to another repository is also called a “push.”

Important

Repository mirroring is configured in the Settings of your Code Studio account, which requires administrative permissions to access. These permissions are available with the Owner role in Code Studio. For more information, see Code Studio user roles.

To set up mirroring Code Studio out to another repository:

  1. Log in to your target repository.

    This is the target repository where you will mirror your Code Studio project.

  2. Generate an access token.

    You will later use this token instead of your password.

  3. Make a note of the repository URL.

  4. Log in to Code Studio and access your project.

  5. In the left navigation, click Settings > Repository.

  6. Click Expand next to Mirroring repositories to expand the section.

  7. Fill in the required information, including:

    • In the Git repository URL, enter the URL where Code Studio will push.

    • In Authentication method, select Password.

    • In Password, enter the token that you generated in Step 2.

  8. Click Mirror repository.

    Verify that the Mirrored repositories table displays your repository.

  9. Click Sync, which is the circular arrows icon to the far right of the table.

    Verify that the mirroring process is functioning.

Repository mirroring is now configured. Any commits made into your Code Studio repository are now automatically mirrored or pushed out to your external repository.

For a complete tutorial on this configuration, see Code Studio: Repository Mirroring.

Mirroring another repository in to Code Studio

The following is an example for mirroring a Bitbucket repository into Code Studio. This methodology can be adapted for use with most git and CI/CD providers.

Note

You must authenticate Code Studio with BitBucket if you want Code Studio to pull code from a private BitBucket repository. You can use multiple ways for authentication. Acquia recommends you to follow this tutorial.

After you set up your Code Studio account and configure your workflow, complete the following instructions to set up repository mirroring with BitBucket:

  1. In Bitbucket:

    1. Create and commit a bitbucket-pipelines.yml file.

    2. Push the yml file to Bitbucket.

      This runs the pipeline and fails.

    3. In the Bitbucket user interface, go to your repository and click Settings.

    4. In the Pipelines section, click SSH keys.

    5. Generate a new SSH key or upload your own SSH key.

    6. Copy the resulting public key to your clipboard.

    7. In the Known Hosts section on the same page, enter gitcode.acquia.com.

    8. Click Fetch and then add host.

  2. In Code Studio:

    1. Log in to the Code Studio user interface or the link provided upon creation in the Cloud IDE.

    2. Navigate to the respective Code Studio project.

    3. Click Settings > Repository > Deploy Keys.

    4. In the Key field, paste the public key that you generated in Bitbucket.

    5. In the Name field, enter a name for the key.

    6. Select the Write access allowed checkbox.

    7. Click Add key.

      The system adds the key.

  3. In Bitbucket:

    1. Review the following yml file example and adjust the code to your needs:

      clone:
        depth: full
      pipelines:
        default:
          - step:
            script:
              - git branch
              - git push --force [email protected]:<CLIENT_GROUP>/<ACQUIA_PROJECT> $BITBUCKET_BRANCH
      
    2. Add the code to your bitbucket-pipelines.yml file.

    3. Commit the file.

      A pipeline process starts. This time it should succeed.

Any subsequent commits and creation/deletion of a branch are mirrored to Code Studio.

Note

This only mirrors git history. It does not mirror any metadata generated in BitBucket such as issues and comments in PRs.