How to use github that’s not open to internet in Azure Pipelines
Your organization has Enterprise Github on premises but it’s open only to your company network. Now you would like to use it with Azure Pipelines but DevOps can’t connect to it because DevOps runs in public cloud. What to do?
Well, you can always use on-prem DevOps aka Azure DevOps Server. But if that’s not an option and you really want to use Azure Pipelines.
Agents to the rescue
If you have possibility to run build agent on premises instead of hosted agent, you’re in luck. When running builds with self hosted agents in your company network, pipelines naturally will have access to your Enterprise Github. Here’s a link to how you can setup your self hosted agent: Self-hosted Windows agents.
“Other Git” approach
When you have setup your self hosted agent, let’s have a look how to setup your build pipeline. Before creating build pipeline, let’s setup a service connection to your on prem repo. Open DevOps project settings and click Service Connections under Pipelines.
Click New service connection and choose Other Git from the dropdown. Type a name for connection, your on prem git repo url and credentials. Also uncheck Attempt accessing this Git server from Azure Pipelines checkbox before clicking OK.
Create a new build pipeline and choose Other Git as a code source. Now if pipeline hasn’t already chosen the connection you created in the step before click change and pick the connection you just created. Change the branch if needed and click Continue. Now you can continue building your build pipeline to do the things you need. Just remember to pick your self hosted agent for Agent Pool.
Build Pipeline Trigger
In this approach you can’t use continuous integration trigger because Azure Pipelines can’t access your repo. But you can schedule for example nightly builds with Scheduled option.
Conclusion
So now you’ve learned how to access git repos behind firewalls or otherwise not visible to Azure Pipelines. This is a quite simple trick but I thought that it wasn’t documented very well, so I hope this helps a little.