/** * Returns all the registered {@link CrumbIssuer} descriptors. */ public static DescriptorExtensionList<CrumbIssuer, Descriptor<CrumbIssuer>> all() { return Jenkins.getInstance().<CrumbIssuer, Descriptor<CrumbIssuer>>getDescriptorList(CrumbIssuer.class); }
@Override public Object getTarget() { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); return this; }
public String getCommand() { return RunIdMigrator.getUnmigrationCommandLine(Jenkins.getInstance().getRootDir()); } }
static <T extends Annotation> List<IndexItem<T,Object>> listDelta(Class<T> annotationType, List<? extends IndexItem<?,Object>> old) { // list up newly discovered components final List<IndexItem<T,Object>> delta = Lists.newArrayList(); ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader; for (IndexItem<T,Object> ii : Index.load(annotationType, Object.class, cl)) { if (!old.contains(ii)) { delta.add(ii); } } return delta; }
/** * Returns those node properties which can be configured as global node properties. * * @since 1.520 */ public static List<NodePropertyDescriptor> getGlobalNodePropertyDescriptors() { List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>(); Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class); for (NodePropertyDescriptor npd : list) { if (npd.isApplicableAsGlobal()) { result.add(npd); } } return result; }
@Initializer(after=EXTENSIONS_AUGMENTED) public void verify() { Jenkins h = Jenkins.getInstance(); for (Descriptor d : h.getExtensionList(Descriptor.class)) { PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass()); String id; try { id = d.getId(); } catch (Throwable t) { LOGGER.log(Level.SEVERE,MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} reported an exception for ID", d, p == null ? "???" : p.getLongName(), d.getDisplayName()),t); problems.add(d); continue; } if (id==null) { LOGGER.severe(MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} has null ID", d, p==null?"???":p.getLongName(), d.getDisplayName())); problems.add(d); } } }
@Override public List<? extends ToolInstaller> getDefaultInstallers() { try { Class<? extends ToolInstaller> jdkInstallerClass = Jenkins.getInstance().getPluginManager() .uberClassLoader.loadClass("hudson.tools.JDKInstaller").asSubclass(ToolInstaller.class); Constructor<? extends ToolInstaller> constructor = jdkInstallerClass.getConstructor(String.class, boolean.class); return Collections.singletonList(constructor.newInstance(null, false)); } catch (ClassNotFoundException e) { return Collections.emptyList(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Unable to get default installer", e); return Collections.emptyList(); } }
@RequirePOST @Deprecated public HttpResponse doPin() throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ LOGGER.log(WARNING, "Call to pin plugin has been ignored. Plugin name: " + shortName); return HttpResponses.ok(); }
private static final File getBaseDir() { File baseDir; String baseEnv = System.getenv("BASE"); if (baseEnv != null) { baseDir = new File(baseEnv); } else { LOGGER.log(Level.WARNING, "Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME"); baseDir = Jenkins.getInstance().getRootDir(); } return baseDir; }
protected List<String> getPossibleViewNames(String baseName) { List<String> names = new ArrayList<String>(); for (Facet f : WebApp.get(Jenkins.getInstance().servletContext).facets) { if (f instanceof JellyCompatibleFacet) { JellyCompatibleFacet jcf = (JellyCompatibleFacet) f; for (String ext : jcf.getScriptExtensions()) names.add(baseName +ext); } } return names; }
/** * @deprecated replaced by {@link Slave.SlaveDescriptor#nodePropertyDescriptors(Slave)} * @since 2.12 */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.12") public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) { List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>(); Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class); for (NodePropertyDescriptor npd : list) { if (npd.isApplicable(clazz)) { result.add(npd); } } return result; }
public ComputerLauncher getLauncher() { if (launcher == null && !StringUtils.isEmpty(agentCommand)) { try { launcher = (ComputerLauncher) Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.slaves.CommandLauncher").getConstructor(String.class, EnvVars.class).newInstance(agentCommand, null); agentCommand = null; save(); } catch (Exception x) { LOGGER.log(Level.WARNING, "could not update historical agentCommand setting to CommandLauncher", x); } } // Default launcher does not use Work Directory return launcher == null ? new JNLPLauncher(false) : launcher; }
@RequirePOST @Deprecated public HttpResponse doUnpin() throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ LOGGER.log(WARNING, "Call to unpin plugin has been ignored. Plugin name: " + shortName); return HttpResponses.ok(); }
@Override protected void fix(TaskListener listener) throws Exception { LOGGER.info("Initiating a re-keying of secrets. See "+getLogFile()); SecretRewriter rewriter = new SecretRewriter(); try { PrintStream log = listener.getLogger(); log.println("Started re-keying " + new Date()); int count = rewriter.rewriteRecursive(Jenkins.getInstance().getRootDir(), listener); log.printf("Completed re-keying %d files on %s\n",count,new Date()); new RekeySecretAdminMonitor().done.on(); LOGGER.info("Secret re-keying completed"); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Fatal failure in re-keying secrets",e); Functions.printStackTrace(e, listener.error("Fatal failure in rewriting secrets")); } }
/** * Returns all the registered {@link NodeMonitor} descriptors. */ public static DescriptorExtensionList<NodeMonitor,Descriptor<NodeMonitor>> all() { return Jenkins.getInstance().<NodeMonitor,Descriptor<NodeMonitor>>getDescriptorList(NodeMonitor.class); } }
public DoubleLaunchChecker() { home = Jenkins.getInstance().getRootDir(); }
@Override @Restricted(NoExternalUse.class) public Object getTarget() { if (!SKIP_PERMISSION_CHECK) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); } return this; }
/** * Does the opposite of {@link #toNameList(Collection)}. */ public static <T extends Item> List<T> fromNameList(ItemGroup context, @Nonnull String list, @Nonnull Class<T> type) { final Jenkins jenkins = Jenkins.getInstance(); List<T> r = new ArrayList<T>(); if (jenkins == null) { return r; } StringTokenizer tokens = new StringTokenizer(list,","); while(tokens.hasMoreTokens()) { String fullName = tokens.nextToken().trim(); if (StringUtils.isNotEmpty(fullName)) { T item = jenkins.getItem(fullName, context, type); if(item!=null) r.add(item); } } return r; }
/** * Returns the list of {@link NodePropertyDescriptor} appropriate to the supplied {@link Slave}. * * @param it the {@link Slave} or {@code null} to assume the slave is of type {@link #clazz}. * @return the filtered list * @since 2.12 */ @Nonnull @SuppressWarnings("unchecked") // used by Jelly EL only @Restricted(NoExternalUse.class) // used by Jelly EL only public final List<NodePropertyDescriptor> nodePropertyDescriptors(@CheckForNull Slave it) { List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>(); Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class); for (NodePropertyDescriptor npd : it == null ? DescriptorVisibilityFilter.applyType(clazz, list) : DescriptorVisibilityFilter.apply(it, list)) { if (npd.isApplicable(clazz)) { result.add(npd); } } return result; }
@Initializer(after = InitMilestone.PLUGINS_PREPARED, before = InitMilestone.PLUGINS_STARTED, fatal = false) public static void load() throws IOException { Map<String, Boolean> overrides = ExtensionList.lookup(CustomClassFilter.class).get(Contributed.class).overrides; overrides.clear(); Enumeration<URL> resources = Jenkins.getInstance().getPluginManager().uberClassLoader.getResources("META-INF/hudson.remoting.ClassFilter"); while (resources.hasMoreElements()) { try (InputStream is = resources.nextElement().openStream()) { for (String entry : IOUtils.readLines(is, StandardCharsets.UTF_8)) { if (entry.matches("#.*|\\s*")) { // skip } else if (entry.startsWith("!")) { overrides.put(entry.substring(1), false); } else { overrides.put(entry, true); } } } } Logger.getLogger(Contributed.class.getName()).log(Level.FINE, "plugin-defined entries: {0}", overrides); }