2

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: enter image description here

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?

Sormita Chakraborty
  • 1,015
  • 2
  • 19
  • 36

1 Answers1

4

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.

enter image description here

Result:

enter image description here

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

enter image description here

Result:

enter image description here

Vito Liu
  • 7,525
  • 1
  • 8
  • 17
  • the error is no more there but when I commit a file to github repo, my azure devops pipeline is not getting triggered, neither is this pipeline getting triggered. – Sormita Chakraborty Nov 23 '20 at 08:50
  • Hi @SormitaChakraborty, I have updated the answer, please check the update1 and then kindly share the result here. – Vito Liu Nov 23 '20 at 09:26
  • Hi @SormitaChakraborty, Just checking in to see whether this issue is still blocking you now? Any update for this issue? – Vito Liu Nov 24 '20 at 02:29
  • I am trying the second approach that you have provided but that way the Build status will not show in Azure boards, also the workitems status related to PR merge etc. Because the entire metadata would be in GitHub. – Sormita Chakraborty Nov 24 '20 at 09:05
  • Hi @SormitaChakraborty, Since the initial issue has been solved, would you mind accepting the answer and creating a new ticket for the latest issue? it could help other community members who get the same issues and we could archive this thread. You could also share the detail info in the new ticket, such as screenshot, reproduce steps and expected result. We will help you resolve it as soon as possible. Thanks – Vito Liu Nov 24 '20 at 09:44