🤝
Resources - External (Unlisted)
  • Mirroring
    • Azure DevOps
    • GitHub
    • GitLab
Powered by GitBook
On this page
  1. Mirroring

Azure DevOps

This page describes the steps needed to mirror a repo from Copia to Azure DevOps. This process has been tested to work for users who have Two-Factor Authentication enabled.

PreviousMirroringNextGitHub

Last updated 2 years ago

Note: These instructions are provided as a basic guideline for mirroring Copia repositories to Azure DevOps. It is up to the customer to implement the Copia repositories into their Pipelines as they desire. These instructions are only intended for one-way mirroring.

Copia is providing these instructions to help customers. We do not officially support this feature and cannot guarantee the accuracy of these instructions.

A video demonstration of this process can be found .

  1. In Azure, create a Project or find an existing project

  2. In Azure, go to Pipelines, then select New Pipeline

  3. On the "Where is your code?" screen, select "Other Git"

  4. Create a new Service Connection for the repository.

    1. Name the connection appropriately using a naming convention that makes sense for your team. We recommend indicating which user's credentials were used to create the Service Connection as part of the naming convention.

    2. Under "Git repository URL", copy and paste the Copia URL ()

    3. Under "User name", enter the Copia username of a user who has access to the repository

    4. Under "Password / Token", enter the password of the Copia user who has access to the repository or enter an Access Token that can be created at (Note: Currently, Copia only generates Access Tokens that have full access to your account)

    5. Set the value for "Default branch for manual and scheduled builds" according to your Copia repo's default branch name

    6. Click Okay to close out of the pop-up window.

  5. On the "Select a template" page, scroll down to select the "Empty pipeline" option, or select a template that your company uses for pipelines

  6. On the Pipeline page, name your Pipeline and change the "Agent Specification" to ubuntu-22.04

  7. If you are using Git LFS in the repository (or if you plan to), click on "Get sources", and then select the option to "Checkout files from LFS". This will download files from LFS. More information for checking out files with LFS can be found .

  8. On the "Tasks" tab and under "Pipeline", click on "Agent job" and check the box "Allow scripts to access the OAuth token" under the "Additional options" dropdown

  9. On the "Tasks" tab and under "Pipeline" and "Agent job", click the "Add task" button and search for and select "Bash Script"

  10. In the PowerShell window that opens, change the Type to "Inline", and then paste the code below seen at the end of the steps.

  11. Select the "Variables" tab and enter the following variables and their corresponding values

    1. AzureRepo: URL to the repository in Azure ()

      1. Note: Do Not include any text before dev.azure.com at the beginning of the URL.

    2. AzureRepo_PAT: Azure repository Personal Access Token. You must generate this PAT yourself and give it access to the target repository

      1. Generate a PAT by navigating to the "Repos" section in the Azure DevOps project and then click the "Clone" button and then "Generate Git Credentials"

    3. AzureRepo_USER: User associated with the AzureRepo_PAT

  12. If you want the Azure Pipeline to check Copia for changes to the repo on some sort of interval, select the "Triggers" tab, check "Enable continuous integration", and then set the polling interval

  13. Save the pipeline

  14. Manually Run the pipeline

  15. If the Pipeline executed successfully, you should see a green check mark in the "Runs" tab of the Pipelines page

set -e

echo "*****Git pulling all branches****"
git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git checkout master
git pull --all --no-commit

echo "*****Git removing remote origin****"
git remote rm origin

echo "*****Git remote add****"
destURL="https://${AZUREREPO_PAT}@${AZUREREPO}"
git remote add --mirror=fetch origin "${destURL}"

echo "*****Git configure Azure credentials****"
B64Pat="$(echo -n "${AZUREREPO_USER}:${AZUREREPO_PAT}" | base64 --wrap=0)"
git config http.extraHeader "Authorization: Basic $B64Pat"

echo "*****Git push to Azure Repos****"
git push origin --all -f
here
https://app.copia.io/<ORG_NAME>/<REPO_NAME>
https://app.copia.io/user/settings/applications
here
dev.azure.com/<USERNAME>/git/<PROJECT_NAME>
Tutorial - Azure Mirroring (LFS version)Created with CloudApp
Page cover image
Logo