DEV Community

Alexey Ryazhskikh
Alexey Ryazhskikh

Posted on • Edited on

3 1

Access to GO modules in private Azure DevOps repositories

If you tried using $(System.AccessToken) to authorize git downloading go module from you private Azure DevOps git repository, you could face with the following error:

fatal: unable to connect to dev.azure.com:
Enter fullscreen mode Exit fullscreen mode

Official Microsoft documentation asks you to create PAT token for access git repoisitories:
https://learn.microsoft.com/en-us/azure/devops/repos/git/go-get?view=azure-devops#https

But you can use $(System.AccessToken) of pipeline identity instead. So you can avoid storing PAT token and renew it on expiration.

Go to Project Settings => Pipelines => Settings and make sure you have "Protect access to repositories in YAML pipelines" checkbox disabled. It will allow pipeline identities access other git repositories:

Image description

Be sure *GOPRIVATE * environment variable set to dev.azure.com

GOPRIVATE=dev.azure.com
Enter fullscreen mode Exit fullscreen mode

After you added it you can execute the following commaind in your pipeline:

git config --global url."https://test:$(System.AccessToken)@dev.azure.com/<organization>/<project>/_git/<repo>".insteadOf "https://dev.azure.com/<organization>/<project>/<repo>"
Enter fullscreen mode Exit fullscreen mode

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay