/** * Checks if "java" is in PATH on the given node. * * <p> * If it's not, then the user must specify a configured JDK, * so this is often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
@Override public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // TODO support Unix scripts with interpreter line (see Shell.buildCommandLine) FilePath script = dir.createTextTempFile("hudson", getCommandFileExtension(), command); try { String cmd[] = getCommandCall(script); int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(getToolHome()); }
private Launcher getLastBuiltLauncher(AbstractBuild build, Launcher launcher, BuildListener listener) { AbstractProject project = build.getProject(); Node lastBuiltOn = project.getLastBuiltOn(); Launcher lastBuiltLauncher = launcher; if (lastBuiltOn != null) { lastBuiltLauncher = lastBuiltOn.createLauncher(listener); } return lastBuiltLauncher; }
private Launcher launcher() { return node().createLauncher(listener); }
public String getCleartoolExe(Node node, TaskListener listener) throws IOException, InterruptedException { ClearCaseInstallation installation = this; installation = installation.forNode(node, listener); if (StringUtils.isNotBlank(installation.getHome())) { // If an installation is specified, use it return PathUtil.convertPathForOS(installation.getHome() + "/" + CLEARTOOL_EXE, node.createLauncher(listener).decorateFor(node).isUnix()); } else { // Otherwise, fallback to a default case where cleartool is in PATH return CLEARTOOL_EXE_FALLBACK; } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // XXX support Windows batch scripts, Unix scripts with interpreter line, etc. (see CommandInterpreter subclasses) FilePath script = dir.createTextTempFile("hudson", ".sh", command); try { String[] cmd = {"sh", "-e", script.getRemote()}; int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(toolHome); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // XXX support Windows batch scripts, Unix scripts with interpreter line, etc. (see CommandInterpreter subclasses) FilePath script = dir.createTextTempFile("hudson", ".sh", command); try { String[] cmd = {"sh", "-e", script.getRemote()}; int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(toolHome); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // XXX support Windows batch scripts, Unix scripts with interpreter line, etc. (see CommandInterpreter subclasses) FilePath script = dir.createTextTempFile("hudson", ".sh", command); try { String[] cmd = {"sh", "-e", script.getRemote()}; int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(toolHome); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // XXX support Windows batch scripts, Unix scripts with interpreter line, etc. (see CommandInterpreter subclasses) FilePath script = dir.createTextTempFile("hudson", ".sh", command); try { String[] cmd = {"sh", "-e", script.getRemote()}; int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(toolHome); }
@Override public boolean processWorkspaceBeforeDeletion(AbstractProject<?, ?> project, FilePath workspace, Node node) throws IOException, InterruptedException { if (node == null) { // HUDSON-7663 : deleting a job that has never run return true; } StreamTaskListener listener = StreamTaskListener.fromStdout(); Launcher launcher = node.createLauncher(listener); ClearTool ct = createClearTool(null, createClearToolLauncher(listener, project.getSomeWorkspace().getParent().getParent(), launcher)); try { if (isUseDynamicView() && !isCreateDynView()) { return true; } AbstractBuild<?, ?> latestBuildOnNode = null; for(AbstractBuild<?, ?> build : project.getBuilds()) { if (node.equals(build.getBuiltOn())) { latestBuildOnNode = build; break; } } if (latestBuildOnNode == null) { latestBuildOnNode = project.getLastBuild(); } BuildVariableResolver buildVariableResolver = new BuildVariableResolver(latestBuildOnNode); ct.rmviewtag(generateNormalizedViewName(buildVariableResolver)); } catch (Exception e) { Logger.getLogger(AbstractClearCaseScm.class.getName()).log(Level.WARNING, "Failed to remove ClearCase view", e); } return true; }
/** * Checks if "java" is in PATH on the given node. * * <p> * If it's not, then the user must specify a configured JDK, * so this is often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
/** * Checks if "java" is in PATH on the given node. * * <p> * If it's not, then the user must specify a configured JDK, * so this is often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
/** * Checks if "java" is in PATH on the given node. * * <p> If it's not, then the user must specify a configured JDK, so this is * often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java", "-fullversion").stdout(listener).join() == 0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
/** * Checks if "java" is in PATH on the given node. * * <p> * If it's not, then the user must specify a configured JDK, * so this is often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
/** * Checks if "java" is in PATH on the given node. * * <p> * If it's not, then the user must specify a configured JDK, * so this is often useful for form field validation. */ public static boolean isDefaultJDKValid(Node n) { try { TaskListener listener = new StreamTaskListener(new NullStream()); Launcher launcher = n.createLauncher(listener); return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedLocation = preferredLocation(tool, node); PrintStream out = log.getLogger(); try { if(!acceptLicense) { out.println(Messages.JDKInstaller_UnableToInstallUntilLicenseAccepted()); return expectedLocation; } // already installed? FilePath marker = expectedLocation.child(".installedByHudson"); if (marker.exists() && marker.readToString().equals(id)) { return expectedLocation; } expectedLocation.deleteRecursive(); expectedLocation.mkdirs(); Platform p = Platform.of(node); URL url = locate(log, p, CPU.of(node)); out.println("Downloading "+url); FilePath file = expectedLocation.child(p.bundleFileName); file.copyFrom(url); // JDK6u13 on Windows doesn't like path representation like "/tmp/foo", so make it a strict platform native format by doing 'absolutize' install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote()); // successfully installed file.delete(); marker.write(id, null); } catch (DetectionFailedException e) { out.println("JDK installation skipped: "+e.getMessage()); } return expectedLocation; }
@Override public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // TODO support Unix scripts with interpreter line (see Shell.buildCommandLine) FilePath script = dir.createTextTempFile("hudson", getCommandFileExtension(), command); try { String cmd[] = getCommandCall(script); int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(getToolHome()); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedLocation = preferredLocation(tool, node); PrintStream out = log.getLogger(); try { if(!acceptLicense) { out.println(Messages.JDKInstaller_UnableToInstallUntilLicenseAccepted()); return expectedLocation; } // already installed? FilePath marker = expectedLocation.child(".installedByHudson"); if (marker.exists() && marker.readToString().equals(id)) { return expectedLocation; } expectedLocation.deleteRecursive(); expectedLocation.mkdirs(); Platform p = Platform.of(node); URL url = locate(log, p, CPU.of(node)); out.println("Downloading "+url); FilePath file = expectedLocation.child(p.bundleFileName); file.copyFrom(url); // JDK6u13 on Windows doesn't like path representation like "/tmp/foo", so make it a strict platform native format by doing 'absolutize' install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote()); // successfully installed file.delete(); marker.write(id, null); } catch (DetectionFailedException e) { out.println("JDK installation skipped: "+e.getMessage()); } return expectedLocation; }
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
static void doRetrieve(String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception { // Adapted from CpsScmFlowDefinition: SCMStep delegate = new GenericSCMStep(scm); delegate.setPoll(false); // TODO we have no API for determining if a given SCMHead is branch-like or tag-like; would we want to turn on polling if the former? delegate.setChangelog(changelog); FilePath dir; Node node = Jenkins.getActiveInstance(); if (run.getParent() instanceof TopLevelItem) { FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) run.getParent()); if (baseWorkspace == null) { throw new IOException(node.getDisplayName() + " may be offline"); } dir = baseWorkspace.withSuffix(getFilePathSuffix() + "libs").child(name); } else { // should not happen, but just in case: throw new AbortException("Cannot check out in non-top-level build"); } Computer computer = node.toComputer(); if (computer == null) { throw new IOException(node.getDisplayName() + " may be offline"); } try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) { delegate.checkout(run, lease.path, listener, node.createLauncher(listener)); // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care? // Copy sources with relevant files from the checkout: lease.path.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target); } }