Last active
October 7, 2021 08:07
-
-
Save PennyQ/949df917c43fc87417f44afaecfccd10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: project_name | |
trigger: | |
branches: | |
include: | |
- master | |
- develop | |
# User defined parameters | |
variables: | |
- name: UserName | |
value: "username" | |
- name: UserEmail | |
value: "useremail" | |
- name: OriginRepo | |
value: "https://dev.azure.com/yourOrgName/originProjectName/_git/originRepoName" | |
- name: TargetRepo | |
value: "https://dev.azure.com/yourOrgName/targetProjectName/_git/targetRepoName" | |
stages: | |
- stage: Mirror_to_Target | |
jobs: | |
- job: MirrorToTarget | |
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), | |
eq(variables['Build.SourceBranch'], 'refs/heads/develop')) | |
pool: | |
name: 'Private Pool Docker' | |
steps: | |
- bash: | | |
git config --global user.name $(UserName) | |
git config --global user.email $(UserEmail) | |
git config --global credential.authority basic | |
git config --global http.sslVerify "false" | |
# the personal account token is defined as pipeline variable encrypted | |
B64_PAT=$(printf "%s"":$(PAT)" | base64) | |
echo ${B64_PAT} | |
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" clone --bare $(OriginRepo) | |
git config -l | |
echo "git clone done" | |
cd originRepoName.git | |
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" push --mirror $(TargetRepo) | |
echo "git mirror done" | |
cd .. | |
rm -rf originRepoName.git | |
displayName: 'Mirror the repo from the Origin project to the Target project' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment