@Override public Step newInstance(Map<String, Object> arguments) throws Exception { arguments = new HashMap<>(arguments); if (arguments.containsKey("url") || arguments.containsKey("credentialsId")) { if (arguments.containsKey("registry")) { throw new IllegalArgumentException("cannot mix url/credentialsId with registry"); } arguments.put("registry", new DockerRegistryEndpoint((String) arguments.remove("url"), (String) arguments.remove("credentialsId"))); } else if (!arguments.containsKey("registry")) { throw new IllegalArgumentException("must specify url/credentialsId (or registry)"); } return super.newInstance(arguments); }
/** Constructs a step execution automatically according to {@link AbstractStepDescriptorImpl#getExecutionType}. */ @Override public final StepExecution start(StepContext context) throws Exception { AbstractStepDescriptorImpl d = (AbstractStepDescriptorImpl) getDescriptor(); return prepareInjector(context, this).getInstance(d.getExecutionType()); }
@Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { diskPools = req.bindJSONToList(DiskPool.class, formData.get("diskPools")); save(); return super.configure(req, formData); }
@Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { templates = req.bindJSONToList(Template.class, formData.get("templates")); save(); return super.configure(req, formData); }
@Override public AbstractFileOrTextStep newInstance(Map<String, Object> arguments) throws Exception { AbstractFileOrTextStep step = (AbstractFileOrTextStep) super.newInstance(arguments); if (isBlank(step.getFile()) && isBlank(step.getText())) { throw new IllegalArgumentException(Messages.AbstractFileOrTextStepDescriptorImpl_missingRequiredArgument(getFunctionName())); } return step; } }
/** Constructs a step execution automatically according to {@link AbstractStepDescriptorImpl#getExecutionType}. */ @Override public final StepExecution start(StepContext context) throws Exception { AbstractStepDescriptorImpl d = (AbstractStepDescriptorImpl) getDescriptor(); return prepareInjector(context, this).getInstance(d.getExecutionType()); }
@Override public Step newInstance(StaplerRequest req, JSONObject formData) throws FormException { if (req == null) { // should not happen return super.newInstance(null, formData); } // A modified version of RequestImpl.TypePair.convertJSON. // Works around the fact that Stapler does not call back into Descriptor.newInstance for nested objects (JENKINS-31458); // and propertiesMap virtual field name; and null values for unselected properties. List<JobProperty> properties = new ArrayList<JobProperty>(); ClassLoader cl = req.getStapler().getWebApp().getClassLoader(); @SuppressWarnings("unchecked") Set<Map.Entry<String,Object>> entrySet = formData.getJSONObject("propertiesMap").entrySet(); for (Map.Entry<String,Object> e : entrySet) { if (e.getValue() instanceof JSONObject) { String className = e.getKey().replace('-', '.'); // decode JSON-safe class name escaping Class<? extends JobProperty> itemType; try { itemType = cl.loadClass(className).asSubclass(JobProperty.class); } catch (ClassNotFoundException x) { throw new FormException(x, "propertiesMap"); } JobPropertyDescriptor d = (JobPropertyDescriptor) Jenkins.getActiveInstance().getDescriptorOrDie(itemType); JSONObject more = (JSONObject) e.getValue(); JobProperty property = d.newInstance(req, more); if (property != null) { properties.add(property); } } } return new JobPropertyStep(properties); }
@Override public Step newInstance(StaplerRequest req, JSONObject formData) throws FormException { if (req == null) { // should not happen return super.newInstance(null, formData); } // A modified version of RequestImpl.TypePair.convertJSON. // Works around the fact that Stapler does not call back into Descriptor.newInstance for nested objects (JENKINS-31458); // and propertiesMap virtual field name; and null values for unselected properties. List<JobProperty> properties = new ArrayList<JobProperty>(); ClassLoader cl = req.getStapler().getWebApp().getClassLoader(); @SuppressWarnings("unchecked") Set<Map.Entry<String,Object>> entrySet = formData.getJSONObject("propertiesMap").entrySet(); for (Map.Entry<String,Object> e : entrySet) { if (e.getValue() instanceof JSONObject) { String className = e.getKey().replace('-', '.'); // decode JSON-safe class name escaping Class<? extends JobProperty> itemType; try { itemType = cl.loadClass(className).asSubclass(JobProperty.class); } catch (ClassNotFoundException x) { throw new FormException(x, "propertiesMap"); } JobPropertyDescriptor d = (JobPropertyDescriptor) Jenkins.getActiveInstance().getDescriptorOrDie(itemType); JSONObject more = (JSONObject) e.getValue(); JobProperty property = d.newInstance(req, more); if (property != null) { properties.add(property); } } } return new JobPropertyStep(properties); }
@Override public Step newInstance(StaplerRequest req, JSONObject formData) throws FormException { BuildTriggerStep step = (BuildTriggerStep) super.newInstance(req, formData);