@Deprecated public GroovyHookScript(String hook) { this(hook, Jenkins.getActiveInstance()); }
@Override protected int run() throws Exception { Jenkins.getActiveInstance().doCancelQuietDown(); return 0; } }
@Override protected int run() throws Exception { Jenkins.getActiveInstance().doQuietDown(block, timeout); return 0; } }
@Override protected Iterable<Node> getNodes() { return Jenkins.getActiveInstance().getNodes(); }
private static File getTargetFile(String name) { return new File(Jenkins.getActiveInstance().getPluginManager().rootDir,name+".jpi"); } }
protected UnlabeledNodesIterator() { super(Jenkins.getActiveInstance().getNodes().iterator()); }
/** * Computes the key that identifies this Hudson among other Hudsons that the user has a credential for. */ @VisibleForTesting String getPropertyKey() { Jenkins j = Jenkins.getActiveInstance(); String url = j.getRootUrl(); if (url!=null) return url; return j.getLegacyInstanceId(); }
/** * Get the stored version of Jenkins, as stored by * {@link #doConfigSubmit(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)}. * <p> * Parses the version into {@link VersionNumber}, or null if it's not parseable as a version number * (such as when Jenkins is run with "mvn hudson-dev:run") * @since 2.0 */ @Restricted(NoExternalUse.class) public @CheckForNull static VersionNumber getStoredVersion() { return toVersion(Jenkins.getActiveInstance().version); }
/** * URLs to download from. */ public List<String> getUrls() { List<String> updateSites = new ArrayList<String>(); for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) { String siteUrl = site.getUrl(); int baseUrlEnd = siteUrl.indexOf("update-center.json"); if (baseUrlEnd != -1) { String siteBaseUrl = siteUrl.substring(0, baseUrlEnd); updateSites.add(siteBaseUrl + "updates/" + url); } else { LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl); } } return updateSites; }
@Override protected int run() throws Exception { Jenkins.getActiveInstance().getQueue().clear(); return 0; }
@Override protected int run() { // this allows the caller to manipulate the JVM state, so require the admin privilege. Jenkins.getActiveInstance().checkPermission(Jenkins.RUN_SCRIPTS); // this being remote means no jline capability is available System.setProperty("jline.terminal", UnsupportedTerminal.class.getName()); TerminalFactory.reset(); StringBuilder commandLine = new StringBuilder(); for (String arg : args) { if (commandLine.length() > 0) { commandLine.append(" "); } commandLine.append(arg); } Groovysh shell = createShell(stdin, stdout, stderr); return shell.run(commandLine.toString()); }
/** * Gets all the job properties configured for this job. */ @SuppressWarnings({"unchecked", "rawtypes"}) public Map<JobPropertyDescriptor, JobProperty<? super JobT>> getProperties() { Map result = Descriptor.toMap((Iterable) properties); if (logRotator != null) { result.put(Jenkins.getActiveInstance().getDescriptorByType(BuildDiscarderProperty.DescriptorImpl.class), new BuildDiscarderProperty(logRotator)); } return result; }
@Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonSource instanceof JSONObject) { JSONObject json = (JSONObject) jsonSource; if (isApplicable(targetTypeErasure, json)) { LOGGER.log(Level.FINE, "switching to newInstance {0} {1}", new Object[] {targetTypeErasure.getName(), json}); try { return Jenkins.getActiveInstance().getDescriptor(targetTypeErasure).newInstance(Stapler.getCurrentRequest(), json); } catch (Exception x) { LOGGER.log(Level.WARNING, "falling back to default instantiation " + targetTypeErasure.getName() + " " + json, x); } } } else { LOGGER.log(Level.FINER, "ignoring non-object {0}", jsonSource); } return oldInterceptor.onConvert(targetType, targetTypeErasure, jsonSource); }
public void doCommand(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException { final Jenkins jenkins = Jenkins.getActiveInstance(); jenkins.checkPermission(Jenkins.READ); // Strip trailing slash final String commandName = req.getRestOfPath().substring(1); CLICommand command = CLICommand.clone(commandName); if (command == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND, "No such command"); return; } req.setAttribute("command", command); req.getView(this, "command.jelly").forward(req, rsp); }
@RequirePOST public HttpResponse doDoUninstall() throws IOException { Jenkins jenkins = Jenkins.getActiveInstance(); jenkins.checkPermission(Jenkins.ADMINISTER); archive.delete(); // Redo who depends on who. jenkins.getPluginManager().resolveDependantPlugins(); return HttpResponses.redirectViaContextPath("/pluginManager/installed"); // send back to plugin manager }
/** * Auto-discovers {@link OptionHandler}s and add them to the given command line parser. */ protected void registerOptionHandlers() { try { for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,Class.class)) { Type t = Types.getBaseClass(c, OptionHandler.class); CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c); } } catch (IOException e) { throw new Error(e); } }
protected void runCli(Connection c) throws IOException, InterruptedException { ChannelBuilder cb; String name = "CLI channel from " + socket.getInetAddress(); // Connection can contain cipher wrapper, which can't be NIO-ed. // if (hub!=null) // cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting); // else cb = new ChannelBuilder(name, Computer.threadPoolForRemoting); Channel channel = cb .withMode(Mode.BINARY) .withRestricted(true) .withBaseLoader(Jenkins.getActiveInstance().pluginManager.uberClassLoader) .build(new BufferedInputStream(c.in), new BufferedOutputStream(c.out)); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel)); channel.join(); } }
@Override protected int run() throws Exception { final Jenkins jenkins = Jenkins.getActiveInstance(); jenkins.checkPermission(View.CREATE); View newView; try { newView = View.createViewFromXML(viewName, stdin); } catch (Failure ex) { throw new IllegalArgumentException("Invalid view name: " + ex.getMessage()); } final String newName = newView.getViewName(); if (jenkins.getView(newName) != null) { throw new IllegalStateException("View '" + newName + "' already exists"); } jenkins.addView(newView); return 0; } }
@Override protected int run() throws Exception { if (!Jenkins.getActiveInstance().hasPermission(Jenkins.READ)) { throw new AccessDeniedException("You must authenticate to access this Jenkins.\n" + CLI.usage()); } if (command != null) return showCommandDetails(); showAllCommands(); return 0; }
@Override protected int run() throws Exception { final Jenkins jenkins = Jenkins.getActiveInstance(); jenkins.checkPermission(Computer.CREATE); final Node newNode = (Node) Jenkins.XSTREAM2.fromXML(stdin); if (nodeName != null) { // Using deprecated method but it's contract is preserved newNode.setNodeName(nodeName); } if(newNode instanceof Slave) { //change userId too User user = User.current(); ((Slave) newNode).setUserId(user==null ? "anonymous" : user.getId()); } if (jenkins.getNode(newNode.getNodeName()) != null) { throw new IllegalStateException("Node '" + newNode.getNodeName() + "' already exists"); } jenkins.addNode(newNode); return 0; }