欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Github 和 Azure DevOps 的代码同步

最编程 2024-06-10 11:24:10
...
第二步,选择你的代码库,这里我选的是Ant-Design-Blazor

第三步,选择模板,这里图片截不下了,往下拉选择Starter pipeline

YAML内容如下,注意username里的‘@’要替换成‘%40’

关于如何编写Pipeline YAML可以参考微软的文档 https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema
 1 # Starter pipeline
 2 # Start with a minimal pipeline that you can customize to build and deploy your code.
 3 # Add steps that build, run tests, deploy, and more:
 4 # https://aka.ms/yaml
 5 variables: # pipeline-level 
 6   branch: 'azure_branch'
 7  
 8 trigger:
 9 - master
10 pool:
11   vmImage: 'ubuntu-latest'
12 steps:
13 - script: |
14    git remote add github https://<username>:<password>@github.com/Brian-Ding/ant-design-blazor.git
15    git checkout -b $(branch)
16    git push -u github $(branch)
17    
18    
19   displayName: 'Command Line Script'

【从Github到Azure DevOps】

前面的操作都和之前类似,只是记得Connect那一步要选择Github

 1 steps:
 2 - script: |
 3    mkdir sync
 4    cd sync
 5    git clone https://github.com/xxx/xxx.git
 6    cd <github project>
 7    git remote add azure https://<Azure DevOps Organization>:<token>@dev.azure.com/<Azure DevOps Organization>/<project>/_git/<repo.git> 8    
 9    git branch -D $(branch)
10    git checkout -b $(branch)
11        
12    git push -d azure $(branch)
13    git push -u azure $(branch) --force
14   displayName: 'Command Line Script'

推荐阅读