DEV Community

Alexey Ryazhskikh
Alexey Ryazhskikh

Posted on • Updated on

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
Enter fullscreen mode Exit fullscreen mode

Official Microsoft documentation asks you to create PAT token for access git repoisitories:

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
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)<organization>/<project>/_git/<repo>".insteadOf "<organization>/<project>/<repo>"
Enter fullscreen mode Exit fullscreen mode

Latest comments (0)