Private Scoped Registries + Unity Cloud Builds

Hi! Is there a way to configure Unity Cloud Builds to build a project that uses some packages from a private scoped registry? Locally we use a upmconfig.toml file for authentication, but I found no way to configure this in Unity Cloud Builds. Thanks!

1 Like

Hey there,

Unfortunately, this is not possible and there are no plans to support this at present.

That’s a shame! Not having support for it at the moment is understandable, but not having plans to support it in the near future is not. You should at least include a big warning in both Cloud Builds and UPM documentation to let people know that these two Unity technologies do not work together.

2 Likes

For anybody interested in solving this problem, you can do the following:

  • Create a bash script and place it somewhere in your Unity project(e.g. “Assets/CloudBuilds/Scripts/pre-build.sh”) with the following content:
    #!/bin/bash
    echo “[YOUR_UPM_SERVICE_ADDRESS]” >> ~/.upmconfig.toml
    echo “token = ‘$NPM_TOKEN’” >> ~/.upmconfig.toml
    echo “email = ‘$NPM_TOKEN_EMAIL’” >> ~/.upmconfig.toml
    echo “alwaysAuth = true” >> ~/.upmconfig.toml

  • Open the Cloud Builds Dashboard->Config->Advanced Options->EDIT ADVANCED OPTIONS and add the path to the script created at step #1
    7089643--844243--upload_2021-4-29_14-32-36.png

  • Open the Cloud Builds Dashboard->Config->Environment Variables->EDIT ENVIRONMENT VARIABLES and add the following two variables:
    7089643--844252--upload_2021-4-29_14-36-50.png
    NPM_TOKEN = your NPM access token
    NPM_TOKEN_EMAIL = the email used to generate the token

You should now be able to build.

7 Likes

Hey @SebastianRM !

Thanks for sharing your solution, looks great but on my side Unity Cloud doesn’t even think about talking to our GitLab server. I also created a global (besides the user) upmconfig file and double-checked all the content and variables.

I also did some logging within the Cloud Console; files are created as expected but the Package Manager is unable to fetch the packages from our registry and the token is not used at all.

If you have any further hints, I would appreciate it! :slight_smile:
(My guess is, GitLab is somewhat blocking authentication…)

Cheers!
Chris

!

@SebastianRM - I do have the dependencies on nexus and tried following the same you mentioned. Created the pre-build.sh as suggested. Looks like the file .upmconfig.toml seems be getting created and able to cat the content of the file.

But for some reason, the file is not getting picked up during the build and am getting the below error message

376: [Unity] An error occurred while resolving packages:
377: [Unity]   Project has invalid dependencies:
378: [Unity]     games.xxxxxxx.iii-wrapper: Request [GET https://nexus.xxxxxxx.me/repository/xxxxxxx-games/games.xxxxxxx.iii-wrapper] failed because it lacks valid authentication credentials
379: [Unity]   Package games.xxxxxxx.iii-wrapper@1.0.18 has invalid dependencies or related test packages:
380: [Unity]     com.xxxxxxx.unity.package (dependency): Request [GET https://nexus.xxxxxxx.me/repository/xxxxxxx-unity-package/com.xxxxxxx.unity.package] failed because it lacks valid authentication credentials

Any thoughts or pointers is much appreciated !

This somehow used to work, but does not work as of now. Anyone knows how to make it work again?

Based on this post: Pre-Build Script Path windows builders - Unity Services - Unity Discussions

This script works:

#!/bin/bash
path=$USERPROFILE/.upmconfig.toml
unameOut="$(uname -s)"
case "${unameOut}" in
    Darwin*)    path=$HOME/.upmconfig.toml;;
esac
echo ${path}

echo "[npmAuth.'YOUR_UPM_SERVICE_ADDRESS']" >> ${path}
echo "token = '$NPM_TOKEN'" >> ${path}
echo "email = '$NPM_TOKEN_EMAIL'" >> ${path}
echo "alwaysAuth = true" >> ${path}
1 Like