Skip to content

Commit

Permalink
Add work-around for JRE bug, fixes JENKINS-18822.
Browse files Browse the repository at this point in the history
A nice side-effect is the absolute path to the [default] rake executable
that was used will now be logged.
  • Loading branch information
olivierdagenais committed Jul 18, 2013
1 parent cb53c8e commit e7ec392
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/hudson/plugins/rake/Rake.java
@@ -1,5 +1,6 @@
package hudson.plugins.rake;

import static hudson.plugins.rake.Util.findInPath;
import static hudson.plugins.rake.Util.getCanonicalRubies;
import static hudson.plugins.rake.Util.getGemsDir;
import static hudson.plugins.rake.Util.hasGemsInstalled;
Expand Down Expand Up @@ -96,7 +97,23 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
}
args.add(exec.getPath());
} else {
args.add(lastBuiltLauncher.isUnix()?"rake":"rake.bat");
String executable = lastBuiltLauncher.isUnix()?"rake":"rake.bat";
// search PATH to build an absolute path to the executable,
// to work around a bug in Java 7u21 - 7u25
// "JDK-8016721 : (process) Behavior of %~dp0 in .cmd and .bat scripts has changed"
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8016721
String path = null;
try {
final EnvVars env = build.getEnvironment(listener);
path = env.get("PATH");
} catch (IOException e) {
// no big deal; ignore and we'll skip the PATH scan below
}
if (path != null) {
final String pathSeparator = lastBuiltLauncher.isUnix()? ":" : ";";
executable = findInPath(executable, path, pathSeparator);
}
args.add(executable);
}

if (rakeFile != null && rakeFile.length() > 0) {
Expand Down

0 comments on commit e7ec392

Please sign in to comment.