将Github存储库与Azure Devops存储库同步 [英] Synchronize Github repository with Azure Devops repository

查看:63
本文介绍了将Github存储库与Azure Devops存储库同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循以下链接中给出的解决方案:

以下是我的管道Yaml代码:

 触发:分支机构:包括:-'*'变量:system_accesstoken:$(System.AccessToken)水池:vmImage:'ubuntu-latest'脚步:-结帐:自我persistCredentials:true#允许脚本访问系统令牌干净:真实-任务:Bash @ 3名称:SyncRepo输入:targetType:内联"脚本:git config --global user.电子邮件"xxxx@xxx.com"git config --global user.name"sormita"git branch -r |grep -v'\->'|在远程阅读时做git branch --track"$ {remote#origin/}""$ remote";完毕git remote add vsts https://xxx.visualstudio.com/xxx/_git/xxxxgit branch -r |grep -v'\->'|在远程阅读时做git -c http.extraheader =授权:承载$(system_accesstoken)"推送-u vsts"$ {remote#origin/}";完毕 

有人可以帮助我将GitHub存储库与Azure Devops存储库同步吗?

解决方案

它应由您的帐户引起,对此存储库没有贡献权限.

转到项目设置->存储库->单击您要操作的存储库->检查服务帐户 {项目名称} Build Service(xxx),并确保将权限设置为允许.您可以查看下面的图片.

结果:

更新1

在Azure DevOps中创建yaml管道,我们需要选择GitHub作为代码资源,然后选择GitHub存储库,它将 yaml 文件保存在 GitHub Repo 中的 Azure DevOps回购,那么我们可以看到CI触发器.

注意:如果yml文件保存在Azure DevOps存储库中,则如果我们在GitHub中推送代码,它将不会触发构建

结果:

I am trying to follow the solution given in the following link: How to fix Github to Azure DevOps Sync?

My requirement is to trigger Azure Devops pipeline when a commit is done in any branch of GitHub repository. I have already imported the code from GitHub repository using PAT token from GitHub repo. The PAT token is given all access in GitHub repository.

But I am getting the following error:

Following is my pipeline yaml code:

trigger:
  branches:
    include:
    - '*'
variables:
  system_accesstoken: $(System.AccessToken)

pool:
  vmImage: 'ubuntu-latest'

steps:
- checkout: self
  persistCredentials: true    #Allow scripts to access the system token
  clean: true 

- task: Bash@3
  name: SyncRepo
  inputs:
    targetType: 'inline'
    script: |
      git config --global user.email "xxxx@xxx.com"
      git config --global user.name "sormita"
      git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
      git remote add vsts https://xxx.visualstudio.com/xxx/_git/xxxx
      git branch -r | grep -v '\->' | while read remote; do git -c http.extraheader="AUTHORIZATION: bearer $(system_accesstoken)" push -u vsts "${remote#origin/}"; done

Can someone please help me synchronize GitHub repository with Azure Devops repo?

解决方案

It should caused by your account do not have the contribute permission for this repository.

Go Project settings --> Repositories --> click Repos you want to operate -->check the service account {project name} Build Service (xxx) and ensure the permission is set to allow. You could check the pic below.

Result:

Update1

Create yaml pipeline in the Azure DevOps, we need select GitHub as the code resource, then select GitHub repository, it will save the yaml file in the GitHub Repo instead of Azure DevOps repo, then we could see the CI trigger.

Note: If the yml file save in the Azure DevOps repo, it will not trigger the build if we push code in the GitHub

Result:

这篇关于将Github存储库与Azure Devops存储库同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆