Refine search
/** * Set the executor without notifying it about task completion. * The caller <b>must</b> also call {@link #maybeComplete()} * after releasing any problematic locks. */ @Restricted(NoExternalUse.class) public synchronized final void setExecutorWithoutCompleting(@Nonnull Executor executor) { assert this.executor == null; this.executor = executor; }
/** * Closes the item and logs error to the log in the case of error. * Logging will be performed on the {@code WARNING} level. * @param toClose Item to close. Nothing will happen if it is {@code null} * @param logger Logger, which receives the error * @param closeableName Name of the closeable item * @param closeableOwner String representation of the closeable holder * @since 2.19, but TODO update once un-restricted */ @Restricted(NoExternalUse.class) public static void closeAndLogFailures(@CheckForNull Closeable toClose, @Nonnull Logger logger, @Nonnull String closeableName, @Nonnull String closeableOwner) { if (toClose == null) { return; } try { toClose.close(); } catch(IOException ex) { LogRecord record = new LogRecord(Level.WARNING, "Failed to close {0} of {1}"); record.setParameters(new Object[] { closeableName, closeableOwner }); record.setThrown(ex); logger.log(record); } }
/** * Returns the list of {@link ComputerLauncher} descriptors 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 @Restricted(NoExternalUse.class) // intended for use by Jelly EL only (plus hack in DelegatingComputerLauncher) public final List<Descriptor<ComputerLauncher>> computerLauncherDescriptors(@CheckForNull Slave it) { DescriptorExtensionList<ComputerLauncher, Descriptor<ComputerLauncher>> all = Jenkins.getInstance().<ComputerLauncher, Descriptor<ComputerLauncher>>getDescriptorList( ComputerLauncher.class); return it == null ? DescriptorVisibilityFilter.applyType(clazz, all) : DescriptorVisibilityFilter.apply(it, all); }
/** * Return true if the systemId denotes an absolute URI . * * The same algorithm can be seen in {@link URI}, but * implementing this by ourselves allow it to be more lenient about * escaping of URI. * * @deprecated Use {@code isAbsoluteOrSchemeRelativeUri} instead if your goal is to prevent open redirects */ @Deprecated @RestrictedSince("1.651.2 / 2.TODO") @Restricted(NoExternalUse.class) public static boolean isAbsoluteUri(@Nonnull String uri) { int idx = uri.indexOf(':'); if (idx<0) return false; // no ':'. can't be absolute // #, ?, and / must not be before ':' return idx<_indexOf(uri, '#') && idx<_indexOf(uri,'?') && idx<_indexOf(uri,'/'); }
@Nonnull @Restricted(NoExternalUse.class) /*package*/ String getApiTokenInsecure() { if(apiToken == null){ return Messages.ApiTokenProperty_NoLegacyToken(); } String p = apiToken.getPlainText(); if (p.equals(Util.getDigestOf(Jenkins.getInstance().getSecretKey()+":"+user.getId()))) { // if the current token is the initial value created by pre SECURITY-49 Jenkins, we can't use that. // force using the newer value apiToken = Secret.fromString(p=API_KEY_SEED.mac(user.getId())); } return Util.getDigestOf(p); }
/** * If this file is a symlink, returns the link target. * <p>The default implementation always returns null. * Some implementations may not support symlinks under any conditions. * @return a target (typically a relative path in some format), or null if this is not a link * @throws IOException if reading the link, or even determining whether this file is a link, failed * @since 2.118 */ @Restricted(Beta.class) public @CheckForNull String readLink() throws IOException { return null; }
@Extension(ordinal = Double.MAX_VALUE) @Restricted(DoNotUse.class) public static class InternalComputerListener extends ComputerListener { @Override public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException { c.cachedEnvironment = null; } }
/** * 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); }
@Override @Restricted(NoExternalUse.class) public Object getTarget() { if (!SKIP_PERMISSION_CHECK) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); } return this; }
/** * @since 2.12 * @deprecated replaced by {@link Slave.SlaveDescriptor#computerLauncherDescriptors(Slave)} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.12") public static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors() { return Jenkins.getInstance().<ComputerLauncher,Descriptor<ComputerLauncher>>getDescriptorList(ComputerLauncher.class); }
/** * @deprecated implement {@link TaskListener} directly */ @Deprecated @Restricted(NoExternalUse.class) @RestrictedSince("2.91") public abstract class AbstractTaskListener implements TaskListener { private static final long serialVersionUID = 7217626701881006422L; }
@Restricted(NoExternalUse.class) public static String expandVariablesForDirectory(String base, String itemFullName, String itemRootDir) { return Util.replaceMacro(base, ImmutableMap.of( "JENKINS_HOME", Jenkins.getInstance().getRootDir().getPath(), "ITEM_ROOTDIR", itemRootDir, "ITEM_FULLNAME", itemFullName, // legacy, deprecated "ITEM_FULL_NAME", itemFullName.replace(':','$'))); // safe, see JENKINS-12251 }
/** * @since 2.24 * @return true if the slave agent port is enforced on this instance. */ @Restricted(NoExternalUse.class) public boolean isSlaveAgentPortEnforced() { return Jenkins.getInstance().isSlaveAgentPortEnforced(); }
@Restricted(NoExternalUse.class) public boolean isMailerPluginPresent() { try { // mail support has moved to a separate plugin return null != Jenkins.getInstance().pluginManager.uberClassLoader.loadClass("hudson.tasks.Mailer$UserProperty"); } catch (ClassNotFoundException e) { LOGGER.finer("Mailer plugin not present"); } return false; }
@Restricted(DoNotUse.class) // for value.jelly public String getFormattedDescription() { try { return Jenkins.getInstance().getMarkupFormatter().translate(description); } catch (IOException e) { LOGGER.warning("failed to translate description using configured markup formatter"); return ""; } }
/** * Returns the applicable nested computer launcher types. * The default implementation avoids all delegating descriptors, as that creates infinite recursion. * @deprecated use {@link #applicableDescriptors(Slave, Slave.SlaveDescriptor)} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.12") public List<Descriptor<ComputerLauncher>> getApplicableDescriptors() { List<Descriptor<ComputerLauncher>> r = new ArrayList<Descriptor<ComputerLauncher>>(); for (Descriptor<ComputerLauncher> d : Jenkins.get().getDescriptorList(ComputerLauncher.class)) { if (DelegatingComputerLauncher.class.isAssignableFrom(d.getKlass().toJavaClass())) continue; r.add(d); } return r; } }
@Override @Restricted(NoExternalUse.class) public Object getTarget() { if (!SKIP_PERMISSION_CHECK) { if (!Jenkins.get().hasPermission(Jenkins.READ)) { return null; } } return this; }
@Restricted(NoExternalUse.class) public boolean hasCurrentUserRightToGenerateNewToken(User propertyOwner){ if (ADMIN_CAN_GENERATE_NEW_TOKENS && Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { return true; } User currentUser = User.current(); if (currentUser == null) { // Anonymous return false; } if (Jenkins.getAuthentication() == ACL.SYSTEM) { // SYSTEM user is always eligible to see tokens return true; } return User.idStrategy().equals(propertyOwner.getId(), currentUser.getId()); }
/** * Requires ADMINISTER permission for any operation in here. */ @Restricted(NoExternalUse.class) public Object getTarget() { Jenkins.get().checkPermission(Jenkins.ADMINISTER); return this; }
/** * Returns whether the system needs a restart, and if it is supported * e.g. { restartRequired: true, restartSupported: false } */ @Restricted(DoNotUse.class) // WebOnly public HttpResponse doRestartStatus() throws IOException { JSONObject response = new JSONObject(); Jenkins jenkins = Jenkins.get(); response.put("restartRequired", jenkins.getUpdateCenter().isRestartRequiredForCompletion()); response.put("restartSupported", jenkins.getLifecycle().canRestart()); return HttpResponses.okJSON(response); }