Refine search
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
/** * Used to determine if we want to display the Add button. */ public boolean hasJobFilterExtensions() { return !ViewJobFilter.all().isEmpty(); }
/** * @deprecated as of 1.416 * Use {@link #create(Jenkins, Class)} */ @Deprecated public static <T extends Describable<T>,D extends Descriptor<T>> DescriptorExtensionList<T,D> createDescriptorList(Hudson hudson, Class<T> describableType) { return (DescriptorExtensionList)createDescriptorList((Jenkins)hudson,describableType); }
public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException { Jenkins j = Jenkins.getInstance(); j.checkPermission(Jenkins.ADMINISTER); if (json.has("useSecurity")) { JSONObject security = json.getJSONObject("useSecurity"); j.setDisableRememberMe(security.optBoolean("disableRememberMe", false)); j.setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); j.setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization")); } else { j.disableSecurity();
if (json.has("csrf")) { JSONObject csrf = json.getJSONObject("csrf"); setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer")); } else { setCrumbIssuer(null); if (json.has("viewsTabBar")) { viewsTabBar = req.bindJSON(ViewsTabBar.class, json.getJSONObject("viewsTabBar")); } else {
/** * Really creates a new agent. */ @RequirePOST public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); String fixedName = Util.fixEmptyAndTrim(name); checkName(fixedName); JSONObject formData = req.getSubmittedForm(); formData.put("name", fixedName); // TODO type is probably NodeDescriptor.id but confirm Node result = NodeDescriptor.all().find(type).newInstance(req, formData); app.addNode(result); // take the user back to the agent list top page rsp.sendRedirect2("."); }
/** * Returns all the registered {@link MatrixExecutionStrategyDescriptor}s. */ public static DescriptorExtensionList<MatrixExecutionStrategy,MatrixExecutionStrategyDescriptor> all() { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins != null) { return jenkins.<MatrixExecutionStrategy,MatrixExecutionStrategyDescriptor>getDescriptorList(MatrixExecutionStrategy.class); } else { return DescriptorExtensionList.createDescriptorList((Jenkins)null, MatrixExecutionStrategy.class); } } }
public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException { return newInstanceFromRadioList(parent.getJSONObject(name)); }
/** * Extracts ScriptSource from given form data. * @deprecated Unused. */ @Deprecated protected ScriptSource getScriptSource( final StaplerRequest req, final JSONObject data ) throws FormException { Object scriptSourceObject = data.get("scriptSource"); if (scriptSourceObject instanceof JSONArray) { // Dunno why this happens. Let's fix the JSON object so that // newInstanceFromRadioList() doesn't go mad. JSONArray scriptSourceJSONArray = (JSONArray) scriptSourceObject; JSONObject scriptSourceJSONObject = new JSONObject(); Object nestedObject = scriptSourceJSONArray.get(1); if (nestedObject instanceof JSONObject) { // command/file path scriptSourceJSONObject.putAll((JSONObject) nestedObject); // selected radio button index scriptSourceJSONObject.put("value", scriptSourceJSONArray.get(0)); data.put("scriptSource", scriptSourceJSONObject); } } return ScriptSource.all().newInstanceFromRadioList(data, "scriptSource"); }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.getInstance(); if (json.has("csrf")) { JSONObject csrf = json.getJSONObject("csrf"); j.setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer")); } else { j.setCrumbIssuer(null); } return true; } }
) { if (clazz == null) { clazz = AbstractProjectReference.class; } Jenkins j = Jenkins.getInstance(); getDescriptorList(clazz); if (!ret.isEmpty()) { return ret; getDescriptorList(AbstractProjectReference.class); Descriptor<?> clazzDesc = j.getDescriptor(clazz); ret.add(prd);
@QueryParameter String name, @QueryParameter String mode, @QueryParameter String from ) throws IOException, ServletException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); Node src = app.getNode(from); if(src==null) { if (Util.fixEmpty(from) == null) { NodeDescriptor d = NodeDescriptor.all().findByName(mode); if (d == null) { throw new Failure("No node type ‘" + mode + "’ is known");
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.get(); if (json.has("csrf")) { JSONObject csrf = json.getJSONObject("csrf"); j.setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer")); } else { j.setCrumbIssuer(null); } return true; } }
Jenkins.checkGoodName(name); name = name.trim(); if(parent.getItem(name)!=null) Item src = Jenkins.getInstance().getItem(from, parent); if(src==null) { if(Util.fixEmpty(from)==null) if(mode==null) throw new Failure("No mode given"); TopLevelItemDescriptor descriptor = Items.all().findByName(mode); if (descriptor == null) { throw new Failure("No item type ‘" + mode + "’ is known");
@Initializer(after = InitMilestone.JOB_LOADED) public static void migrateJobs() throws IOException { GitLabPushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GitLabPushTrigger.DescriptorImpl.class); if (!oldConfig.jobsMigrated) { GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class); gitLabConfig.getConnections().add(new GitLabConnection( oldConfig.gitlabHostUrl, for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) { GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class); if (trigger != null) {
if (json.has("use_security")) { useSecurity = true; JSONObject security = json.getJSONObject("use_security"); if (security.has("markupFormatter")) { markupFormatter = req.bindJSON(MarkupFormatter.class, security.getJSONObject("markupFormatter")); Hudson.getInstance().setSlaveAgentPort(slaveAgentPort); setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization"));
public DescriptorExtensionList<BuildSelector,Descriptor<BuildSelector>> getBuildSelectors() { final DescriptorExtensionList<BuildSelector, Descriptor<BuildSelector>> list = DescriptorExtensionList.createDescriptorList(Jenkins.getInstance(), BuildSelector.class); // remove from list some of the CopyArchiver build selector that we can't deal with list.remove(WorkspaceSelector.DESCRIPTOR); return list; } }
try { if (jenkins!=null) { for (EndOfTestListener tl : jenkins.getExtensionList(EndOfTestListener.class)) tl.onTearDown(); jenkins.cleanUp(); ExtensionList.clearLegacyInstances(); DescriptorExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances(); throw e; jenkins.setNoUsageStatistics(true); // collecting usage stats from tests are pointless. jenkins.setCrumbIssuer(new TestCrumbIssuer()); jenkins.getJDKs().add(new JDK("default",System.getProperty("java.home")));
private static List<Descriptor<ListViewColumn>> extractOptionalColumns( DescriptorExtensionList<ListViewColumn, Descriptor<ListViewColumn>> extensionList) { return Lists.<Descriptor<ListViewColumn>>newArrayList( extensionList.get(WeatherColumn.DescriptorImpl.class), extensionList.get(StatusColumn.DescriptorImpl.class)); } }