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:
Log in to your target repository.
This is the target repository where you will mirror your Code Studio project.
Generate an access token.
You will later use this token instead of your password.
Make a note of the repository URL.
Log in to Code Studio and access your project.
In the left navigation, click Settings > Repository.
Click Expand next to Mirroring repositories to expand the section.
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.
Click Mirror repository.
Verify that the Mirrored repositories table displays your repository.
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:
In Bitbucket:
Create and commit a
bitbucket-pipelines.yml
file.Push the yml file to Bitbucket.
This runs the pipeline and fails.
In the Bitbucket user interface, go to your repository and click Settings.
In the Pipelines section, click SSH keys.
Generate a new SSH key or upload your own SSH key.
Copy the resulting public key to your clipboard.
In the Known Hosts section on the same page, enter
gitcode.acquia.com
.Click Fetch and then add host.
In Code Studio:
Log in to the Code Studio user interface or the link provided upon creation in the Cloud IDE.
Navigate to the respective Code Studio project.
Click Settings > Repository > Deploy Keys.
In the Key field, paste the public key that you generated in Bitbucket.
In the Name field, enter a name for the key.
Select the Write access allowed checkbox.
Click Add key.
The system adds the key.
In Bitbucket:
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
Add the code to your
bitbucket-pipelines.yml
file.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.