/** * 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)); }
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 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)); }
/** * 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); } }
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()); } };
@SuppressWarnings("deprecation") @Override public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException { // capture the file to the server File local = File.createTempFile("jenkins","parameter"); String name; if (value.isEmpty()) { FileUtils.copyInputStreamToFile(command.stdin, local); name = "stdin"; } else { FilePath src = new FilePath(command.checkChannel(), value); src.copyTo(new FilePath(local)); name = src.getName(); } FileParameterValue p = new FileParameterValue(getName(), local, name); p.setDescription(getDescription()); p.setLocation(getName()); return p; } }
public Channel superCheckChannel() throws AbortException { return super.checkChannel(); }
/** * 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)); }
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 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)); }
@Override public Channel checkChannel() throws AbortException { initPython(); if (pexec.isImplemented(2)) { return (Channel) pexec.execPython("check_channel"); } else { return super.checkChannel(); } }
/** * 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); } }
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()); } };
@SuppressWarnings("deprecation") @Override public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException { // capture the file to the server File local = File.createTempFile("jenkins","parameter"); String name; if (value.isEmpty()) { FileUtils.copyInputStreamToFile(command.stdin, local); name = "stdin"; } else { FilePath src = new FilePath(command.checkChannel(), value); src.copyTo(new FilePath(local)); name = src.getName(); } FileParameterValue p = new FileParameterValue(getName(), local, name); p.setDescription(getDescription()); p.setLocation(getName()); return p; } }