Skip to content

Commit

Permalink
[FIXED JENKINS-29507] Make JenkinsRule useable on systems without glibc
Browse files Browse the repository at this point in the history
  • Loading branch information
vjuranek committed Sep 17, 2015
1 parent 63e6ac6 commit 8f29260
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/hudson/Functions.java
Expand Up @@ -75,6 +75,7 @@
import hudson.util.Area;
import hudson.util.FormValidation.CheckMethod;
import hudson.util.Iterators;
import hudson.util.jna.GNUCLibrary;
import hudson.util.Secret;
import hudson.views.MyViewsTabBar;
import hudson.views.ViewsTabBar;
Expand Down Expand Up @@ -459,6 +460,15 @@ public static Map getEnvVars() {
public static boolean isWindows() {
return File.pathSeparatorChar==';';
}

public static boolean isGlibcSupported() {
try {
GNUCLibrary.LIBC.getpid();
return true;
} catch(Throwable t) {
return false;
}
}

public static List<LogRecord> getLogRecords() {
return Jenkins.logRecords;
Expand Down
6 changes: 3 additions & 3 deletions test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Expand Up @@ -696,7 +696,7 @@ public Maven.MavenInstallation configureDefaultMaven(String mavenVersion, int ma
mvn.copyFrom(JenkinsRule.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
mvn.unzip(new FilePath(buildDirectory));
// TODO: switch to tar that preserves file permissions more easily
if(!Functions.isWindows())
if(Functions.isGlibcSupported())
GNUCLibrary.LIBC.chmod(new File(mvnHome, "bin/mvn").getPath(),0755);

Maven.MavenInstallation mavenInstallation = new Maven.MavenInstallation("default",
Expand All @@ -720,7 +720,7 @@ public Ant.AntInstallation configureDefaultAnt() throws Exception {
File antHome = createTmpDir();
ant.unzip(new FilePath(antHome));
// TODO: switch to tar that preserves file permissions more easily
if(!Functions.isWindows())
if(Functions.isGlibcSupported())
GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);

antInstallation = new Ant.AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
Expand Down Expand Up @@ -2318,7 +2318,7 @@ public boolean isLoggable(LogRecord record) {
// this also prevents tests from falsely advertising Hudson
DNSMultiCast.disabled = true;

if (!Functions.isWindows()) {
if (Functions.isGlibcSupported()) {
try {
GNUCLibrary.LIBC.unsetenv("MAVEN_OPTS");
GNUCLibrary.LIBC.unsetenv("MAVEN_DEBUG_OPTS");
Expand Down

0 comments on commit 8f29260

Please sign in to comment.