Search in sources :

Example 21 with Descriptor

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);
    }
}
Also used : Describable(hudson.model.Describable) TriggerDescriptor(hudson.triggers.TriggerDescriptor) Descriptor(hudson.model.Descriptor) JobPropertyDescriptor(hudson.model.JobPropertyDescriptor)

Example 22 with Descriptor

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()]);
}
Also used : ArrayList(java.util.ArrayList) StepDescriptor(org.jenkinsci.plugins.workflow.steps.StepDescriptor) DeclarativeAgentDescriptor(org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor) ToolDescriptor(hudson.tools.ToolDescriptor) Descriptor(hudson.model.Descriptor) StepDescriptor(org.jenkinsci.plugins.workflow.steps.StepDescriptor) TreeResponse(io.jenkins.blueocean.commons.stapler.TreeResponse) GET(org.kohsuke.stapler.verb.GET)

Aggregations

Descriptor (hudson.model.Descriptor)22 Test (org.junit.Test)9 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)8 ArrayList (java.util.ArrayList)8 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)7 StringParameterDefinition (hudson.model.StringParameterDefinition)6 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)6 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)6 FreeStyleBuild (hudson.model.FreeStyleBuild)5 FreeStyleProject (hudson.model.FreeStyleProject)5 Promotion (hudson.plugins.promoted_builds.Promotion)4 StepDescriptor (org.jenkinsci.plugins.workflow.steps.StepDescriptor)4 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)3 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 AbstractProjectDescriptor (hudson.model.AbstractProject.AbstractProjectDescriptor)3 ParameterDefinition (hudson.model.ParameterDefinition)3 ParameterValue (hudson.model.ParameterValue)3 Jenkins (jenkins.model.Jenkins)3 Describable (hudson.model.Describable)2