public String[] buildCommandLine(FilePath script) { if(command.startsWith("#!")) { // interpreter override int end = command.indexOf('\n'); if(end<0) end=command.length(); List<String> args = new ArrayList<String>(); args.addAll(Arrays.asList(Util.tokenize(command.substring(0,end).trim()))); args.add(script.getRemote()); args.set(0,args.get(0).substring(2)); // trim off "#!" return args.toArray(new String[args.size()]); } else return new String[] { getDescriptor().getShellOrDefault(script.getChannel()), "-xe", script.getRemote()}; }
/** * If this {@link FilePath} represents a file on a particular {@link Computer}, return it. * Otherwise null. * @since 1.571 */ public @CheckForNull Computer toComputer() { Jenkins j = Jenkins.getInstanceOrNull(); if (j != null) { for (Computer c : j.getComputers()) { if (getChannel()==c.getChannel()) { return c; } } } return null; }
public static String getAgentName(FilePath ws) { if (ws.getChannel() != null) { return ws.getChannel() instanceof LocalChannel ? "Master" : ((Channel) ws.getChannel()).getName(); } return "Unknown"; }
@Override protected KeyMaterialFactory newKeyMaterialFactory() throws IOException, InterruptedException { return step.server.newKeyMaterialFactory(job, workspace.getChannel()); }
public String[] buildCommandLine(FilePath script) { if(command.startsWith("#!")) { // interpreter override int end = command.indexOf('\n'); if(end<0) end=command.length(); List<String> args = new ArrayList<String>(); args.addAll(Arrays.asList(Util.tokenize(command.substring(0,end).trim()))); args.add(script.getRemote()); args.set(0,args.get(0).substring(2)); // trim off "#!" return args.toArray(new String[args.size()]); } else return new String[] { getDescriptor().getShellOrDefault(script.getChannel()), "-xe", script.getRemote()}; }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, VirtualChannel, Launcher, TaskListener)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Requires workspace."); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
private FilePath createTemporaryWorkspace(Run<?, ?> run, FilePath workspace, PrintStream logger) throws Exception { logger.println("[WARNING] Performance test: Job workspace contains spaces in path. Virtualenv does not support such path. Creating temporary workspace for virtualenv."); File baseTmpDir = new File(System.getProperty("java.io.tmpdir")); if (baseTmpDir.getAbsolutePath().contains(" ")) { logger.println("[WARNING] Performance test: Temporary folder contains spaces in path."); throw new InvalidPathException(baseTmpDir.getAbsolutePath(), "Virtualenv cannot be installed in workspace that contains spaces in path."); } File tempDir = new File(baseTmpDir.getAbsolutePath(), "perf-test-virtualenv-workspace-" + configJobName(run.getParent().getName())); FilePath tempWorkspace = new FilePath(workspace.getChannel(), tempDir.getAbsolutePath()); tempWorkspace.mkdirs(); return tempWorkspace; }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, FilePath, Launcher, EnvVars, TaskListener, String)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Requires workspace."); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
/** * Makes the key materials available locally for the on-going build * and returns {@link KeyMaterialFactory} that gives you the parameters needed to access it. */ public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Build has no workspace"); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
@Override protected FilePath getRootViewPath(ClearToolLauncher launcher) { return new FilePath(launcher.getWorkspace().getChannel(), viewDrive); } }
/** * Makes the key materials available locally for the on-going build * and returns {@link KeyMaterialFactory} that gives you the parameters needed to access it. */ public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Build has no workspace"); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
protected FilePath getBztWorkingDirectory(FilePath jobWorkspace) { return (workingDirectory != null && !workingDirectory.isEmpty()) ? (isAbsoluteFilePath() ? // absolute workspace new FilePath(jobWorkspace.getChannel(), workingDirectory) : //relative workspace new FilePath(jobWorkspace, workingDirectory) ) : jobWorkspace; }
private static List<PerformanceReportParser> getParserWithAbsolutePath(Run<?, ?> build, FilePath workspace, PrintStream logger, File path, String percentiles) throws IOException, InterruptedException { List<PerformanceReportParser> result = getParserUsingAntPatternAbsolutePath(build, workspace, logger, path, percentiles); if (result != null && !result.isEmpty()) { return result; } if (!path.exists()) { // if report on remote slave FilePath localReport = new FilePath(new File(build.getRootDir(), "/temp/" + path.getName())); localReport.copyFrom(new FilePath(workspace.getChannel(), path.getAbsolutePath())); return Collections.singletonList(getParser(ParserDetector.detect(localReport.getRemote()), path.getName(), percentiles)); } return Collections.singletonList(getParser(ParserDetector.detect(path.getAbsolutePath()), path.getAbsolutePath(), percentiles)); }
@Override public Action getAction(AbstractBuild<?, ?> build, TaskListener listener) throws IOException, InterruptedException, DontTriggerException { assert f.getChannel() == null; // we copied files locally. This file must be local to the master FileParameterValue fv = new FileParameterValue(parameterBinding.parameterName, new File(f.getRemote()), f.getName()); return new ParametersAction(fv); } });
public FilePath normalize(final FilePath path) { assert path != null; String tmp = normalize(path.getRemote()); return new FilePath(path.getChannel(), tmp); }
public static Long calculateWorkspaceDiskUsageForPath(FilePath workspace, ArrayList<FilePath> exceeded) throws IOException, InterruptedException{ Long diskUsage = 0l; if(workspace.exists()){ try{ diskUsage = workspace.getChannel().callAsync(new DiskUsageCallable(workspace, exceeded)).get(Jenkins.getInstance().getPlugin(DiskUsagePlugin.class).getConfiguration().getTimeoutWorkspace(), TimeUnit.MINUTES); } catch(Exception e){ Logger.getLogger(DiskUsageUtil.class.getName()).log(Level.WARNING, "Disk usage fails to calculate workspace for file path " + workspace.getRemote() + " through channel " + workspace.getChannel(),e); } } return diskUsage; }
/** * @param build * @param runner * @return all the paths to remote module roots declared in given build by {@link DebianPackageBuilder}s * @throws DebianizingException */ public static Collection<String> getRemoteModules(AbstractBuild<?, ?> build, Runner runner) throws DebianizingException { ArrayList<String> result = new ArrayList<String>(); for (DebianPackageBuilder builder: getDPBuilders(build)) { result.add(new FilePath(build.getWorkspace().getChannel(), builder.getRemoteDebian(build, runner)).child("..").getRemote()); } return result; }
@Override protected ArgumentListBuilder getArguments(FilePath script) { return new ArgumentListBuilder(getShell(script.getChannel()), isExitCodeIgnored() ? "-x" : "-xe", script.getRemote()); }
private FilePath createFile(final FilePath ws) throws IOException, InterruptedException { return new FilePath(ws.getChannel(), ws.act(new WorkspaceFileCreatorFileCallable(this.workspaceFile))); }
public Map<String, SeleniumRunOptions> getConfigurations() { PluginImpl.getPlugin().validateAdmin(); try { return computer.getNode().getRootPath().getChannel().call(new GetConfigurations()); } catch (Exception e) { return Collections.emptyMap(); } }