如何将Github修复到Azure DevOps Sync? [英] How to fix Github to Azure DevOps Sync?

查看:66
本文介绍了如何将Github修复到Azure DevOps Sync?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure DevOps和Github之间进行了同步,以将Github存储库与Azure Devops中的存储库同步.到去年年底,一切正常.今年,同步不再起作用.该失败消息是致命的:无法读取'https://$(XXXXXXXXXToken)@ yyyyyy.visualstudio.com'的密码:终端提示已禁用'

I have a synchronization between Azure DevOps and Github to sync the Github repo with the repo in Azure Devops. End of last year everything works fine. This year the synchronization do not work anymore. The failure message was fatal: could not read Password for 'https://$(XXXXXXXXXToken)@yyyyyy.visualstudio.com': terminal prompts disabled'

我忘记了PAT将于2019年12月31日到期.因此,我重新创建了管道,而不仅仅是更改PAT的到期日期. facepalm .我的想法是创建一条新的管道以解决问题所在.但是我想我把一切都弄糟了.

I have forgotten, that the PAT expires on 31.12.2019. So I recreated the pipeline, instead of just changing the expiration date of the PAT. facepalm. My idea was to create a new pipeline to get to the point which the problem cause. But I think I made everything worst.

现在,我从以下位置更改了脚本:

Now I changed the Script from:

git push https://$(XXXXXXXToken)@ yyyyyy.visualstudio.com/nnnnn/_git/kkkkkkkk -u --all

收件人:

git push https://$(System.AccessToken)@ yyyyyy.visualstudio.com/nnnnn/_git/kkkkkkkk -u --all

我将令牌更改为"System.AccessToken",因为允许脚本访问OAuth令牌"中的信息说:

I changed the token to 'System.AccessToken', because information at "Allow scripts to access the OAuth token" says:

我撤消了清单中的每个PAT.重新创建管道并将访问权限更改为"System.AccessToken"后,DevOps自动创建一个PAT,如下所示:

I revoked every PAT in my list. After I recreated the pipeline and changed the access to 'System.AccessToken' DevOps automatically creates a PAT, which looks like:

管道运行为绿色,但是Azure DevOps git repo仍未更新.看来,仍然没有与Azure DevOps git repo的连接.管道的日志向我显示,从github存储库中签出可以正常工作.没有失败.

The Pipeline runs green, but the Azure DevOps git repo is still not updated. It seems, there is still no connection to the Azure DevOps git repo. The log of the pipeline shows me, that checking out from the github repo works fine. No failures.

管道YAML代码(我使用YAML编辑器使用UI创建的管道不是Directyl):

The Pipeline YAML code (I have created the pipeline with the UI not directyl with the YAML editor) is:

  • 我在Github网站上安装了Azure Pipelines和Azure Boards App.
  • 我还授权了这两个应用程序,并授权了这两个应用程序使用OAuth.
  • 我在GitHub和Azure DevOps存储库之间也有一个Webhok.Webhook配置为可进行拉取请求,推送和释放
  • 在Azure DevOps中,有一个到我所有GitHub中的Repos的GitHub连接.

有人可以帮助我使同步正常工作吗?

Can someone help me to get the sync working correctly?

推荐答案

我们必须在YAML中声明一个变量,以访问 $(System.AccessToken).请参阅

We have to declare a variable in YAML to access the $(System.AccessToken). See Set variables in pipeline

我可以使用以下YAML管道将Github存储库成功同步到Azure DevOps存储库:(只需相应地替换Azure DevOps git存储库: https://xxx.visualstudio.com/GithubSync/_git/GithubSync )

I can sync the Github repo successfully to Azure DevOps repo using the following YAML pipeline: (Just replace the Azure DevOps git repo accordingly : https://xxx.visualstudio.com/GithubSync/_git/GithubSync)

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: shellexec@0
  inputs:
    code: |
      git config --global user.email "xx@xx.com"
      git config --global user.name "xxx"
      git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
      git remote add vsts https://xxx.visualstudio.com/GithubSync/_git/GithubSync
      git branch -r | grep -v '\->' | while read remote; do git -c http.extraheader="AUTHORIZATION: bearer $(system_accesstoken)" push -u vsts "${remote#origin/}"; done

有关更多信息,请参考此博客:使用VSTS同步GITHUB存储库

Reference this blog for more information : SYNCHRONIZE GITHUB REPOSITORY WITH VSTS

这篇关于如何将Github修复到Azure DevOps Sync?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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