0

I have some code in my GitHub repo. I figured out how to build it through my Azure Pipeline.

Is there a way to link the code as well? I don't know if that necessarily makes sense. I see the option to import a repository and that works for me.

Just curious if there is a way to review a live version of the github code in Azure. Or how are people using Azure DevOps when they have GitHub repository?

Rod
  • 14,529
  • 31
  • 118
  • 230

2 Answers2

2

Azure DevOps supports several source code repo including GitHub. You can use your existing Github repo while creating pipeline. Following screen shot from the Azure DevOps console. This is the 1st step while creating a pipeline where you can connect to your existing repo.

enter image description here

1

If you want to synchronize the github repo code to the azure devops repo, you can do it through the following steps.

For a single branch,push update from github repo to azure devops repo,see below command:

git clone https://github.com/XXX/XXX.git
git config --global user.name "XXX"
git checkout master
git add .
git commit -m "abc"
git push https://{AzureDevopsPAT}@dev.azure.com/{org}/{pro}/_git/delete.git

enter image description here

To loop through all branch in github, use the following command:

git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git push https://$(VSTSToken)@dev.azure.com/xxx/_git/xxx -u --all

In order to kick the build every time there is a code change we need to go to trigger tab and setup like this:

enter image description here

For details ,please refer to this ticket.

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • Would this be a one time sync? If I make changes to GitHub repo will I do this again? – Rod Sep 22 '20 at 13:29
  • We **enabled continuous integration** for the pipeline that uses github repo as the source. Therefore, once the code in github is changed, the pipeline will automatically trigger to complete code synchronization. This is not a one time sync, no need to manually trigger the pipeline every time. – Hugh Lin Sep 23 '20 at 01:45
  • But as far syncing the code between GitHub and Azure Repo the only thing I’ve found is that you can import the code from GitHub but that’s about it. It’s not synced either. I do understand that you can trigger the build off code change in GitHub. – Rod Sep 23 '20 at 03:26
  • After importing the changed code in Github to the azure repo, the code version will also be recorded in the [azure repo commit](https://i.stack.imgur.com/reA08.png). This is synchronization as I understand it. What is the synchronization you want to achieve? – Hugh Lin Sep 23 '20 at 09:56
  • If I make a change in GitHub it doesn’t reflect in Azure Repo – Rod Sep 24 '20 at 03:06
  • Following the steps I gave above, it is possible to reflect the changes of github to azure devosp. Currently this can only be achieved through pipeline. – Hugh Lin Sep 25 '20 at 09:09