#Environment variables
1 messages · Page 1 of 1 (latest)
Moving to a thread to keep this or if main chat.
I do use that call in my build tools to grab the env var from the user level. It works perfectly fine if you are in editor and building with the tools since the SDK was installed on the same user account, which is what manages the environment variable.
When running as a Jenkins job on the build machine with the system user, it doesn't have access to that user variable. It can build successfully after I injected the variable value as a build step, but the method you linked to can't find it.
And, remember me why you cant set it correctly ?
Because the service was running as the system user, it doesn't have any user variables. It feels inconsistent though.
I mean, why wont you set the variable when you initialize the build machine. I believe you should not assume that the build machine would run on the same user or computer every time.
The system level user, which is what is running the jenkins service, doesn't have user environment variables
Then set it ?
You can't. It doesn't have user variables. The System user is a special case for running windows services
Though maybe I'm not understanding the system user 100% as I did notice weird inconsistent behaviour.
Initially, Unity build would outright fail because Unity itself couldn't access the environment variable. I ended up creating a system variable with the value as well as using the EnvInject plugin to jenkins to set it. One or the other solved the issue, but the build tools are failing a post build step where it uses GetEnvironmentVariable to try and pull the value from User variables.
Then I do not know what to say to you. I've setup a build machine effortless for PS5, PS4, NX, Steam, X1, XSX and I had no issue whatever with environment variable. Maybe you are not using the correct approach. Maybe use an Admin user instead of a System user.
That was what I ended up doing
The build machine is hitting the same targets you mentioned. Only one of them uses user side vars, the rest all worked out of the box with no changes as the SDKs set the variables at the system level
If that's the best approach, I'll leave it that way.
If I may ask a follow up, since you have things working on your end, how do you manage updating the Env Vars between jobs? Are you setting the paths manually per build in the CI tool or in the projects themselves (or some other method)?
I have a build machine per project (6 month to 2 years iteration 2 project at a time). Not the ideal setup but I have the policy of not overdesigning solution and I try to scale up as our team grow.
Question of profitability.
Ah, that makes sense
My team usually have more projects on the go at once so having a machine each is bit much for us.
It's been a while since I've set up a build machine, very long overdue. Jenkins with an admin user has solved all the current issues and I really want to avoid VMs per project to handle the SDK swapping. I'll run some tests with setting the variables in PowerShell as the first build action and hope that it works well enough. I try to get all our projects I have control over to the same Unity version for simplicity but it's not always possible.