/** * Shows {@link Channel#classLoadingTime}. * @since 1.495 */ public long getClassLoadingTime() throws IOException, InterruptedException { return channel.call(new LoadingTime(false)); }
/** * Shows {@link Channel#resourceLoadingTime}. * @since 1.495 */ public long getResourceLoadingTime() throws IOException, InterruptedException { return channel.call(new LoadingTime(true)); }
public List<LogRecord> getLogRecords() throws IOException, InterruptedException { if(channel==null) return Collections.emptyList(); else return channel.call(new SlaveLogFetcher()); }
/** * Get the OS description. */ public String getOSDescription() throws IOException, InterruptedException { return channel.call(new DetectOS()) ? "Unix" : "Windows"; }
/** * Shows {@link Channel#classLoadingCount}. * @since 1.495 */ public int getClassLoadingCount() throws IOException, InterruptedException { return channel.call(new LoadingCount(false)); }
/** * Shows {@link Channel#resourceLoadingCount}. * @since 1.495 */ public int getResourceLoadingCount() throws IOException, InterruptedException { return channel.call(new LoadingCount(true)); }
/** * Get the agent version */ public String getSlaveVersion() throws IOException, InterruptedException { return channel.call(new SlaveVersion()); }
@Override public void preOnline(Computer c, Channel channel, FilePath root, TaskListener listener) { if (disabled) return; try { if (channel.call(new ChannelSwapper())) listener.getLogger().println("Evacuated stdout"); } catch (Throwable e) { LOGGER.fine("Fatal problem swapping file descriptors " + c.getName()); } }
protected @Nonnull Charset getClientCharset() throws IOException, InterruptedException { if (encoding != null) { return encoding; } if (channel==null) // for SSH, assume the platform default encoding // this is in-line with the standard SSH behavior return Charset.defaultCharset(); String charsetName = checkChannel().call(new GetCharset()); try { return Charset.forName(charsetName); } catch (UnsupportedCharsetException e) { LOGGER.log(Level.FINE,"Server doesn't have charset "+charsetName); return Charset.defaultCharset(); } }
/** * Convenience method for subtypes to obtain environment variables of the client. * @deprecated Specific to Remoting-based protocol. */ @Deprecated protected String getClientEnvironmentVariable(String name) throws IOException, InterruptedException { return checkChannel().call(new GetEnvironmentVariable(name)); }
/** * Convenience method for subtypes to obtain the system property of the client. * @deprecated Specific to Remoting-based protocol. */ @Deprecated protected String getClientSystemProperty(String name) throws IOException, InterruptedException { return checkChannel().call(new GetSystemProperty(name)); }
/** * Loads the script from the argument. */ private String loadScript() throws CmdLineException, IOException, InterruptedException { if(script==null) throw new CmdLineException(null, "No script is specified"); if (script.equals("=")) return IOUtils.toString(stdin); return checkChannel().call(new ScriptLoader(script)); } }
/** * Shows {@link Channel#classLoadingPrefetchCacheCount}. * @return -1 in case that capability is not supported * @since 1.519 */ public int getClassLoadingPrefetchCacheCount() throws IOException, InterruptedException { if (!channel.remoteCapability.supportsPrefetch()) { return -1; } return channel.call(new LoadingPrefetchCacheCount()); }
@VisibleForTesting /*package*/ void install(Channel channel, @CheckForNull SlaveComputer c) { if (pingTimeoutSeconds < 1 || pingIntervalSeconds < 1) { LOGGER.warning("Agent ping is disabled"); return; } // set up ping from both directions, so that in case of a router dropping a connection, // both sides can notice it and take compensation actions. try { channel.call(new SetUpRemotePing(pingTimeoutSeconds, pingIntervalSeconds)); LOGGER.fine("Set up a remote ping for " + channel.getName()); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to set up a ping for " + channel.getName(), e); } setUpPingForChannel(channel, c, pingTimeoutSeconds, pingIntervalSeconds, true); }
@Override public void preOnline(Computer c, Channel channel, FilePath root, TaskListener listener) throws IOException, InterruptedException { for (LogRecorder recorder : Jenkins.getInstance().getLog().logRecorders.values()) { for (Target t : recorder.targets) { channel.call(new SetLevel(t.name, t.getLevel())); } } } }
public static void applyConfiguration(SAXReader reader, Object context) throws IOException, InterruptedException { Collection<ParserConfigurator> all = Collections.emptyList(); if (Jenkins.getInstanceOrNull()==null) { Channel ch = Channel.current(); if (ch!=null) all = ch.call(new GetParserConfigurators()); } else all = all(); for (ParserConfigurator pc : all) pc.configure(reader,context); } private static class GetParserConfigurators extends SlaveToMasterCallable<Collection<ParserConfigurator>, IOException> {
/** * If the command is currently running inside a build, return it. Otherwise null. */ protected Run optCurrentlyBuilding() throws CmdLineException { try { CLICommand c = CLICommand.getCurrent(); if (c==null) throw new IllegalStateException("Not executing a CLI command"); String[] envs = c.checkChannel().call(new GetCharacteristicEnvironmentVariables()); if (envs[0]==null || envs[1]==null) return null; Job j = Jenkins.getActiveInstance().getItemByFullName(envs[0],Job.class); if (j==null) throw new IllegalArgumentException("No such job: "+envs[0]); try { Run r = j.getBuildByNumber(Integer.parseInt(envs[1])); if (r==null) throw new IllegalArgumentException("No such build #"+envs[1]+" in "+envs[0]); if (!r.isBuilding()) { throw new IllegalStateException(r + " is not currently being built"); } return r; } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid build number: "+envs[1]); } } catch (IOException | InterruptedException e) { throw new IllegalArgumentException("Failed to identify the build being executed",e); } }
channel.addListener(listener); String slaveVersion = channel.call(new SlaveVersion()); log.println("Remoting version: " + slaveVersion); VersionNumber agentVersion = new VersionNumber(slaveVersion); boolean _isUnix = channel.call(new DetectOS()); log.println(_isUnix? hudson.model.Messages.Slave_UnixSlave():hudson.model.Messages.Slave_WindowsSlave()); String defaultCharsetName = channel.call(new DetectDefaultCharset()); remoteFS = channel.call(new AbsolutePath(remoteFS)); log.println("NOTE: Relative remote path resolved to: "+remoteFS); channel.call(new SlaveInitializer(DEFAULT_RING_BUFFER_SIZE)); SecurityContext old = ACL.impersonate(ACL.SYSTEM); try {
protected int run() throws Exception { Jenkins h = Jenkins.getActiveInstance(); h.checkPermission(Jenkins.READ); // where is this build running? BuildIDs id = checkChannel().call(new BuildIDs()); if (!id.isComplete()) throw new IllegalStateException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = h.getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new IllegalStateException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }
public Authentication authenticate() throws AuthenticationException, IOException, InterruptedException { if (userName==null) return command.getTransportAuthentication(); // no authentication parameter. fallback to the transport if (passwordFile!=null) try { password = new FilePath(command.checkChannel(), passwordFile).readToString().trim(); } catch (IOException e) { throw new BadCredentialsException("Failed to read "+passwordFile,e); } if (password==null) password = command.checkChannel().call(new InteractivelyAskForPassword()); if (password==null) throw new BadCredentialsException("No password specified"); UserDetails d = doAuthenticate(userName, password); return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities()); } };