Package hudson.Proc

Examples of hudson.Proc.LocalProc


            // try simple delete first (whether exists() or not, as it may be symlink pointing
            // to non-existent target), but fallback to "rm -rf" to delete non-empty dir.
            File symlinkFile = new File(baseDir, symlinkPath);
            if (!symlinkFile.delete() && symlinkFile.exists())
                // ignore a failure.
                new LocalProc(new String[]{"rm","-rf", symlinkPath},new String[0],listener.getLogger(), baseDir).join();

            Integer r=null;
            if (!SYMLINK_ESCAPEHATCH) {
                try {
                    r = LIBC.symlink(targetPath,symlinkFile.getAbsolutePath());
                    if (r!=0) {
                        r = Native.getLastError();
                        errmsg = LIBC.strerror(r);
                    }
                } catch (LinkageError e) {
                    // if JNA is unavailable, fall back.
                    // we still prefer to try JNA first as PosixAPI supports even smaller platforms.
                    if (PosixAPI.supportsNative()) {
                        r = PosixAPI.get().symlink(targetPath,symlinkFile.getAbsolutePath());
                    }
                }
            }
            if (r==null) {
                // if all else fail, fall back to the most expensive approach of forking a process
                r = new LocalProc(new String[]{
                    "ln","-s", targetPath, symlinkPath},
                    new String[0],listener.getLogger(), baseDir).join();
            }
            if (r!=0)
                listener.getLogger().println(String.format("ln -s %s %s failed: %d %s",targetPath, symlinkFile, r, errmsg));
View Full Code Here


            // replace variables in command line
            String[] jobCmd = new String[ps.commands.size()];
            for ( int idx = 0 ; idx < jobCmd.length; idx++ )
              jobCmd[idx] = jobEnv.expand(ps.commands.get(idx));

            return new LocalProc(jobCmd, Util.mapToEnv(jobEnv),
                    ps.reverseStdin ?LocalProc.SELFPUMP_INPUT:ps.stdin,
                    ps.reverseStdout?LocalProc.SELFPUMP_OUTPUT:ps.stdout,
                    ps.reverseStderr?LocalProc.SELFPUMP_OUTPUT:ps.stderr,
                    toFile(ps.pwd));
        }
View Full Code Here

            // replace variables in command line
            String[] jobCmd = new String[ps.commands.size()];
            for ( int idx = 0 ; idx < jobCmd.length; idx++ )
              jobCmd[idx] = jobEnv.expand(ps.commands.get(idx));

            return new LocalProc(jobCmd, Util.mapToEnv(jobEnv), ps.stdin, ps.stdout, ps.stderr, toFile(ps.pwd));
        }
View Full Code Here

            // try simple delete first (whether exists() or not, as it may be symlink pointing
            // to non-existent target), but fallback to "rm -rf" to delete non-empty dir.
            File symlinkFile = new File(baseDir, symlinkPath);
            if (!symlinkFile.delete() && symlinkFile.exists())
                // ignore a failure.
                new LocalProc(new String[]{"rm","-rf", symlinkPath},new String[0],listener.getLogger(), baseDir).join();

            int r;
            if (!SYMLINK_ESCAPEHATCH) {
                try {
                    r = LIBC.symlink(targetPath,symlinkFile.getAbsolutePath());
                    if (r!=0) {
                        r = Native.getLastError();
                        errmsg = LIBC.strerror(r);
                    }
                } catch (LinkageError e) {
                    // if JNA is unavailable, fall back.
                    // we still prefer to try JNA first as PosixAPI supports even smaller platforms.
                    r = PosixAPI.get().symlink(targetPath,symlinkFile.getAbsolutePath());
                }
            } else // escape hatch, until we know that the above works well.
                r = new LocalProc(new String[]{
                    "ln","-s", targetPath, symlinkPath},
                    new String[0],listener.getLogger(), baseDir).join();
            if(r!=0)
                listener.getLogger().println(String.format("ln -s %s %s failed: %d %s",targetPath, symlinkFile, r, errmsg));
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of hudson.Proc.LocalProc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.