Synchronize Github repository with Azure Devops repository

人走茶凉 提交于 2021-02-11 15:09:11

问题


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?


回答1:


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:



来源:https://stackoverflow.com/questions/64963634/synchronize-github-repository-with-azure-devops-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!