【问题标题】:Synchronize Github repository with Azure Devops repository将 Github 存储库与 Azure Devops 存储库同步
【发布时间】:2021-03-05 21:15:41
【问题描述】:

我正在尝试遵循以下链接中给出的解决方案: How to fix Github to Azure DevOps Sync?

我的要求是在 GitHub 存储库的任何分支中完成提交时触发 Azure Devops 管道。我已经使用 GitHub 存储库中的 PAT 令牌从 GitHub 存储库导入了代码。 PAT 令牌被授予 GitHub 存储库中的所有访问权限。

但我收到以下错误:

以下是我的管道 yaml 代码:

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

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

【问题讨论】:

    标签: git github azure-devops azure-pipelines


    【解决方案1】:

    应该是你的账号没有这个仓库的投稿权限造成的。

    Go Project settings --> Repositories --> 点击你要操作的Repos -->勾选服务账号{project name} Build Service (xxx),确保权限设置为允许。您可以查看下面的图片。

    结果:

    更新1

    在 Azure DevOps 中创建 yaml 管道,我们需要选择 GitHub 作为代码资源,然后选择 GitHub 存储库,它会将 yaml 文件保存在 GitHub Repo 中,而不是 Azure DevOps repo,然后我们可以看到 CI 触发器。

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

    结果:

    【讨论】:

    • 错误不再存在,但是当我将文件提交到 github repo 时,我的 azure devops 管道没有被触发,这个管道也没有被触发。
    • 嗨@SormitaChakraborty,我已经更新了答案,请检查更新1,然后在这里分享结果。
    • 嗨@SormitaChakraborty,刚刚检查一下这个问题现在是否仍然阻止你?这个问题有什么更新吗?
    • 我正在尝试您提供的第二种方法,但这样构建状态将不会显示在 Azure 板中,与 PR 合并等相关的工作项状态也不会显示。因为整个元数据将在 GitHub 中。
    • 嗨@SormitaChakraborty,由于最初的问题已经解决,您介意接受答案并为最新问题创建新票吗?它可以帮助遇到相同问题的其他社区成员,我们可以存档此线程。您还可以分享新工单中的详细信息,例如屏幕截图、重现步骤和预期结果。我们会尽快帮您解决。谢谢
    猜你喜欢
    • 2021-12-14
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    相关资源
    最近更新 更多