Weird bug when building with batchmode in Jenkins

System : win10-ver2004
Unity : 2020.1f1/2019.4
Jenkins : 2.222.1

I use Jenkins to do some CI job for my project, the Jenkins will run a powershell script, and the powershell script will run unity in batchmode and execute a static method to build the project.

The problem is, if I run the script manually, everything works fine, but if I run from Jenkins, the build will fail.

The build log shows Unity can’t find JDK path, but I set JDK path manually, and it works fine when building manually.

I successfully reproduce this with an empty new project, so the problem is not inside my project.

I know it’s probably a Jenkins problem(bug or wrong config), but I don’t understand why it stops unity from getting the correct path(in Windows registry).

Fixed.

On windows, Jenkins by default will run as SYSTEM user, so it don’t know HKEY_CURRENT_USER registry for other user who is using Unity.

Solution : run Jenkins with non SYSTEM user(change setting in system service), start unity once and set preference for that user. Or run Jenkins directly with the user that is using Unity.