本文整理了Java中hudson.model.Node.createLauncher()
方法的一些代码示例,展示了Node.createLauncher()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.createLauncher()
方法的具体详情如下:
包路径:hudson.model.Node
类名称:Node
方法名:createLauncher
[英]Returns a Launcher for executing programs on this node.
The callee must call Launcher#decorateFor(Node) before returning to complete the decoration.
[中]返回用于在此节点上执行程序的启动器。
被调用方必须在返回以完成装饰之前调用Launcher#decorefor(节点)。
代码示例来源:origin: jenkinsci/jenkins
/**
* 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;
}
}
代码示例来源:origin: jenkinsci/jenkins
@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());
}
代码示例来源:origin: org.jenkins-ci.plugins/rake
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;
}
代码示例来源:origin: jenkinsci/mercurial-plugin
private Launcher launcher() {
return node().createLauncher(listener);
}
代码示例来源:origin: org.jvnet.hudson.plugins/clearcase
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;
}
}
代码示例来源:origin: hudson/hudson-2.x
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);
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
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);
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
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);
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
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);
}
代码示例来源:origin: org.jvnet.hudson.plugins/clearcase
@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;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* 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;
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* 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;
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* 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;
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* 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;
}
}
代码示例来源:origin: hudson/hudson-2.x
/**
* 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;
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
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;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@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());
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
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;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-cps-global-lib
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!