If you’re seeing an error when building a Unity project with Jenkins on Windows, and it looks something like this…
error CS0006: Metadata file 'Unityemail@example.com/UnityEngine.Advertisements.dll' could not be found
…then it’s probably caused by Unity PackageManager (introduced in 2017.2) looking a file in the wrong place. Jenkins uses the SYSTEM account to access files, but Unity doesn’t play nicely with this until version 2018.1.
To solve the problem setup two Environment Variables as seen below to point to the correct location for the files OR install unity 2018.1 which (apparently) has a fix in it. If you use the Environment variables then you’ll need to restart your PC before it’ll work.
Hope it helps