Jenkins/Ubuntu - executeMethod class 'UnityBuild' could not be found.

I have been battling this error for a couple of days now. I came back to my Jenkins setup after a week where the previous build had succeeded then bam, for some inexplicable reason it now throws this error.

This is the project I am building: https://github.com/CarlHalstead/Jenkins-Test

I am at a wits end.

Here is the most recent log:

Here is the log of the last successful build:

Attempting to battle this issue is giving me a migraine so I will be back a little bit to update this post if necessary.
[/quote]

Here is the command I am now executing I think it is a little different to the last successful build but as far as I can tell it is still running Unity with the same command.

[quote]

Paths for reference for Unity installs and Unity licenses (.ulf files)

Each installatuion of Unity should be contained within a folder where the root name is

simply its version e.g. 2019.2.3f1 or 2019.3.1f1

UNITY_PATH="$JENKINS_HOME/UnityInstalls"
UNITY_LICENSE_PATH="$JENKINS_HOME/UnityLicenses"

Within this next block of commands we accomplish a single

task but in a modular fashion!

1. Find a file called ProjectVersion.txt within a folder called ProjectSettings. (This can be anywhere in the workspace)

2. Read said file

3. Using a regular expression, extract the version number used for the project

4. Trim whitespace around the version

cd "$WORKSPACE"
UNITY_VERSION_FILE_PATH="$(find . | grep ProjectSettings/ProjectVersion.txt)"
UNITY_VERSION_CONTENTS=$(cat "$UNITY_VERSION_FILE_PATH")
UNITY_VERSION="$(echo $UNITY_VERSION_CONTENTS | grep -oP '(?<=m_EditorVersion: ).*?(?=m_EditorVersionWithRevision:)')"
UNITY_VERSION="$(echo $UNITY_VERSION | xargs)"

Make a directory within the workspace where the build will be deposited.

Anyone can write to this folder.

mkdir -m 777 -p "$WORKSPACE/Final"

Launch Unity with the desired project and parameters.

"$UNITY_PATH/Unity-$UNITY_VERSION/Editor/Unity" -projectPath "$WORKSPACE/" -logFile "$WORKSPACE/Logs/BuildLog.txt" -executeMethod UnityBuild.BuildPlatforms -buildPath "$WORKSPACE/Final/" -windows64 -linux64 -batchmode -nographics -quit
[/quote]

Did you check that you actually have a static method called UnityBuild.BuildPlatforms available in an editor assembly ?

Definitely, it is right there in my repository and when I check the Workspace through Jenkins it exists in the right place. (Assets/Editor/UnityBuild.cs with a static method called BuildPlatforms). I even made sure to copy/paste the names across and noticed no changes.

Not sure this is related, but the project folder is called “Unity Test” (contains a space character).

You can try to change that to something without a space (UnityTest).

I doubt that is the issue (Due to it working previously with the same name) but I will change it nonetheless as it does bug me that it has a space. Will report back if it fixes anything.

post any updates if u found something :)

Created a new Jenkins project (Simply called ‘Unity’), copied my config over for the most part (Even simplified the command line args a little) and still get the same error.

UnityBuild.cs is very clearly there and very clearly has a static BuildPlatforms method

I am at a loss, I just have no idea what has broken it since the last successful build. Or at least what is causing this specific error which sounds straight forward but clearly isn’t.

I have just seen this in the log:

[quote]
[ScriptCompilation] Recompiling all scripts because: Reload of assemblies failed
Win32Exception: ApplicationName='/var/lib/jenkins/UnityInstalls/Unity-2019.2.3f1/Editor/Data/Tools/RoslynScripts/unity_csc.sh', CommandLine='/noconfig @Temp/UnityTempFile-f6d47c2e09d1c730da82145354c9d813', CurrentDirectory='', Native error= Out of memory
[/quote]

I wonder if this is related. Strange that the build continues printing messages after this point as if nothing has happened.

EDIT:

I am increasing my VM to 2GB of RAM instead of 1GB just for the hell of it to see if it changes anything.

I could not make this up if I tried. The issue is that it did not have enough RAM to compile the code, hence giving the error that my script did not exist. If there is any way to have a better error message, it would be appreciated! (Or an error message in a sensible location instead of the middle of the log!)

Note to anyone who reads this in the future: Your machine may need more RAM!

Personal thanks for trying to help. Without your motivation I may have given up!

Okay, so I got the same issue with my build script. The issue appeared directly after updating to latest IAP 2.2.5 in my case.
I didn’t dig into the problem itself. As for me it looks like that Unity is now obfuscating unused scripts BEFORE launching build (maybe only for building via command line, idk). The solution is to use link.xml or [Preserve] attribute.

Have you solved it?

I also got this issue,

I need rm -rf Library when executeMethod class ‘xxxx’ could not be found.