Cannot authenticate gitlab repository when building from Gitlab CI

Hi,

I have a gitlab CI setup that is building a Unity project using the command line API, on my own Windows machine.

When I run the build locally via cmd, it works. However, running through the CI, it fails to build with:


You may need to set up a Git credentials helper
to access a private repository.```

Gitlab works correctly in the browser, cmd, and third-party GUIs.

I saw some documentation that said I needed to add a upmconfig.toml file with my access token and email address, which I did (to both users/me/.upmconfig.toml and C:/Users/Public/Unity/config/ServiceAccounts/.upmconfig.toml) - opening the project that gitlab had checked out from Unity Hub gave me an toml error (which I subsequently fixed) which seems to suggest it's reading the file and working correctly through Hub, but it still fails on the CI build. If I add garbage into the ServiceAccounts toml, it does not fail, making me think that it is not accessing it at all.

My project builds from the E: drive - could this be causing a problem?

Additional info:
Thread about upmconfig is this one: Npm registry authentication page-2#post-7045042

If I cd into %ALLUSERSPROFILE%\Unity\ it takes me to C:\ProgramData\Unity\ I added a upmconfig file into C:\ProgramData\Unity\config\ServiceAccounts but it does not seem to get checked from there either.

The error you’re getting is from Git authentication but upmconfig is for npm server authentication, so it won’t help you solve your problem. There should be documentation how to set up your Git credentials with your CI, have you tried accessing the Git repository directly using a shell script in your CI, to see if the issue is with the Git configuration or with Unity not being able to find it?

Thanks for your reply, finally got a chance to try it out.

When I try to access git directly, using git ls-remote, it gave me an error: could not find environment variables GITCREDENTIALUSERNAME and/or GITCREDENTIALPASSWORD. After entering those into my CI variables, it gave me the ls-remote output as expected, but it still gives me the Username error when trying to fetch the packages.

Some slight progress - I was able to replace GITCREDENTIALSUSERNAME and GITCREDENTIALSPASSWORD with just a call to git config credential.helper store in the ci script and that works for doing git ls-remote inside the project directory. However, it still does not allow me to download the packages. I’m using https, should I be using SSH?

success! git config --global credential.helper store worked