use of hudson.model.Descriptor in project hudson-2.x by hudson.
the class CascadingUtil method buildExternalProperties.
/**
* Creates {@link ExternalProjectProperty} based on Descriptors collection, StaplerRequest and JSON resonse.
*
* @param req StaplerRequest
* @param json JSONObject
* @param descriptors list of descriptors
* @param owner job to be updated.
* @param <T> Describable
* @throws Descriptor.FormException if any.
*/
@SuppressWarnings("unchecked")
public static <T extends Describable<T>> void buildExternalProperties(StaplerRequest req, JSONObject json, List<Descriptor<T>> descriptors, Job owner) throws Descriptor.FormException {
for (Descriptor d : descriptors) {
String name = d.getJsonSafeClassName();
ExternalProjectProperty<Describable> baseProperty = getExternalProjectProperty(owner, name);
Describable describable = null;
if (json.has(name)) {
describable = d.newInstance(req, json.getJSONObject(name));
}
baseProperty.setValue(describable);
}
}
use of hudson.model.Descriptor in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doPipelineStepMetadata.
/**
* Function to return all step descriptors present in the system when accessed through the REST API
*/
@GET
@TreeResponse
public ExportedPipelineFunction[] doPipelineStepMetadata() {
List<ExportedPipelineFunction> pd = new ArrayList<>();
for (StepDescriptor d : StepDescriptor.all()) {
if (includeStep(d)) {
ExportedPipelineStep step = getStepMetadata(d);
if (step != null) {
pd.add(step);
}
}
}
List<Descriptor<?>> metaStepDescriptors = new ArrayList<Descriptor<?>>();
populateMetaSteps(metaStepDescriptors, Builder.class);
populateMetaSteps(metaStepDescriptors, Publisher.class);
populateMetaSteps(metaStepDescriptors, BuildWrapper.class);
for (Descriptor<?> d : metaStepDescriptors) {
ExportedPipelineFunction metaStep = getStepMetadata(d);
if (metaStep != null) {
pd.add(metaStep);
}
}
return pd.toArray(new ExportedPipelineFunction[pd.size()]);
}
Aggregations