Skip to content

Commit

Permalink
[FIXED JENKINS-29218] improve documentation and feedback when using p…
Browse files Browse the repository at this point in the history
…arametrized path for jenkins installation homes. Note that: we do not re-expand from master env vars twice anymore, we use the path and not the absolute path (that could break things if people used relative paths for Unity3d installs, but it makes the message about unresolved path accurate
  • Loading branch information
lacostej committed Jul 7, 2015
1 parent 70c73f2 commit bd249a4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
Expand Up @@ -67,30 +67,56 @@ public String call() throws IOException {
});
}

private static String checkUnity3dExecutablePath(String home) {
String unityHome = Util.replaceMacro(home, EnvVars.masterEnvVars);
log.fine("UNITY_HOME:" + unityHome);
File value = new File(unityHome);
static class Unity3dExecutablePath {
String home;
String path;
boolean exists;

Unity3dExecutablePath(String home, String path, boolean exists) {
this.home = home;
this.path = path;
this.exists = exists;
}

static Unity3dExecutablePath check(String home) {
File value = new File(home);
File unityExe = getExeFile(value);
log.fine("home " + home + " value " + value + " exe " + unityExe + " path abs " + unityExe.getAbsolutePath() + " path " + unityExe.getPath());
String path = unityExe.getPath(); // getAbsolutePath
boolean exists = value.isDirectory() && unityExe.exists();
return new Unity3dExecutablePath(home, path, exists);
}

File unityExe = getExeFile(value);
boolean isVariableExpanded() {
return !home.contains("$");
}

String path = unityExe.getAbsolutePath();
private static File getExeFile(File unityHome) {
if (Functions.isWindows()) {
return new File(unityHome, "Editor/Unity.exe");
} else { // mac assumed
return new File(unityHome, "Contents/MacOS/Unity");
}
}

if (!value.isDirectory() || !unityExe.exists()) {
throw new RuntimeException(Messages.Unity3d_InvalidUnityHomeConfiguration(value, path));
public String getInvalidInstallMessage() {
return Messages.Unity3d_InvalidUnityHomeConfiguration(new File(home), path);
}

return path;
public String getParametrizedInstallMessage() {
return Messages.Unity3d_UnityHomeNotFullyExpanded(path);
}
}

private static File getExeFile(File unityHome) {
if (Functions.isWindows()) {
return new File(unityHome, "Editor/Unity.exe");
} else { // mac assumed
return new File(unityHome, "Contents/MacOS/Unity");
private static String checkUnity3dExecutablePath(String home) {
Unity3dExecutablePath install = Unity3dExecutablePath.check(home);
if (!install.exists) {
throw new RuntimeException(install.getInvalidInstallMessage());
}
return install.path;
}


/**
* Create a long running task that pipes the Unity3d editor.log into the specified pipe.
* <p>
Expand Down Expand Up @@ -185,10 +211,14 @@ public FormValidation doCheckHome(@QueryParameter String value) {
if (value.equals(""))
return FormValidation.ok();

try {
checkUnity3dExecutablePath(value);
} catch (RuntimeException re) {
return FormValidation.error(re.getMessage());
String unityHome = Util.replaceMacro(value, EnvVars.masterEnvVars);
log.fine("UNITY_HOME:" + unityHome);
Unity3dExecutablePath install = Unity3dExecutablePath.check(unityHome);

if (! install.isVariableExpanded()) {
return FormValidation.ok(install.getParametrizedInstallMessage());
} else if (!install.exists) {
return FormValidation.error(install.getInvalidInstallMessage());
}
return FormValidation.ok();
}
Expand Down
@@ -1,6 +1,7 @@
Unity3d.ExecUnexpectedlyFailed=Unity3d plugin execution unexpectedly failed
Unity3d.UnityExecFailed=Unity3d command line execution failed with status {0}
Unity3d.InvalidUnityHomeConfiguration=The configured Unity3d installation directory ({0}) is not recognized as a Unity3d home directory. Remember that the plugin adds per-platform suffixes and is searching for the executable at {1}.
Unity3d.UnityHomeNotFullyExpanded=Your unity home is parametrized and will be resolved at runtime. Remember that the plugin adds per-platform suffixes and is searching for the executable at {0}
Unity3d.NoUnity3dInstallation=No Unity3d Installation on this node
Unity3d.BuildMarkedAsUnstableBecauseOfStatus=Unity3d command line execution returned non zero status {0}. Build marked as unstable per configuration.
Unity3d.InvalidParamUnstableReturnCodes={0} couldn't be parsed as a comma separated list of integers
Expand Up @@ -7,4 +7,6 @@
This field is <em>optional</em> on the jenkins master if you do not intend to build with unity3d on the master.
Do not forget to configure the location of the installations on your nodes as needed.
</p>

<p>You may use environment variables in the path and define those variables wherever you feel like (master, node, job). The final installation path will be resolved at job execution time.</p>
</div>

0 comments on commit bd249a4

Please sign in to comment.