Java 类hudson.model.ParameterDefinition 实例源码

项目:run-selector-plugin    文件:ParameterizedRunSelectorTest.java   
/**
 * Also applicable for workflow jobs.
 */
@Issue("JENKINS-30357")
@Test
public void testWorkflow() throws Exception {
    FreeStyleProject jobToSelect = j.createFreeStyleProject();
    Run runToSelect = j.assertBuildStatusSuccess(jobToSelect.scheduleBuild2(0));

    WorkflowJob selecter = createWorkflowJob();

    ParameterDefinition paramDef = new StringParameterDefinition(
            "SELECTOR", "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>"
    );
    selecter.addProperty(new ParametersDefinitionProperty(paramDef));

    selecter.setDefinition(new CpsFlowDefinition(String.format("" +
            "def runWrapper = selectRun job: '%s', " +
            " selector: [$class: 'ParameterizedRunSelector', parameterName: '${SELECTOR}'] \n" +
            "assert(runWrapper.id == '%s')", jobToSelect.getFullName(), runToSelect.getId())));

    j.assertBuildStatusSuccess(selecter.scheduleBuild2(0));
}
项目:github-integration-plugin    文件:JobHelper.java   
/**
 * @see jenkins.model.ParameterizedJobMixIn#getDefaultParametersValues()
 */
public static List<ParameterValue> getDefaultParametersValues(Job<?, ?> job) {
    ParametersDefinitionProperty paramDefProp = job.getProperty(ParametersDefinitionProperty.class);
    List<ParameterValue> defValues = new ArrayList<>();

    /*
    * This check is made ONLY if someone will call this method even if isParametrized() is false.
    */
    if (paramDefProp == null) {
        return defValues;
    }

    /* Scan for all parameter with an associated default values */
    for (ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) {
        ParameterValue defaultValue = paramDefinition.getDefaultParameterValue();

        if (defaultValue != null) {
            defValues.add(defaultValue);
        }
    }

    return defValues;
}
项目:yaml-project-plugin    文件:YamlBuild.java   
/** Get the default parameter values for the given delegate */
private ParametersAction getDefaultParametersValues(
    AbstractProject delegate) {
  final ParametersDefinitionProperty property =
      (ParametersDefinitionProperty) delegate.getProperty(
          ParametersDefinitionProperty.class);
  if (property == null) {
    return null;
  }

  final List<ParameterValue> result = Lists.newArrayList();
  for (ParameterDefinition def : property.getParameterDefinitions()) {
    ParameterValue value = def.getDefaultParameterValue();
    if (value != null) {
      result.add(value);
    }
  }

  return new ParametersAction(result);
}
项目:p4-jenkins    文件:ReviewAction.java   
/**
 * It extracts and removes internal parameters from the full list of parameters as they need to be managed
 * in a special way for security reasons (related to SECURITY-170).
 *
 * @param values internal parameters values (internal parameters are defined in {@link #getParameterDefinitions()}
 * @return internal parameters values
 */
private List<ParameterValue> extractAndRemoveInternalParameters(List<ParameterValue> values) {
    List<ParameterValue> internal = new ArrayList<ParameterValue>();
    List<ParameterDefinition> parameterDefinitions = getParameterDefinitions();
    Iterator<ParameterValue> it = values.iterator();
    while (it.hasNext()) {
        ParameterValue next = it.next();
        for (ParameterDefinition pd : parameterDefinitions) {
            if (next.getName().equals(pd.getName())) {
                internal.add(next);
                it.remove();
                break;
            }
        }
    }
    return internal;
}
项目:uno-choice-plugin    文件:DynamicReferenceParameter.java   
@Override
public ParameterDefinition newInstance(StaplerRequest req, JSONObject formData) throws hudson.model.Descriptor.FormException {
    if (req != null) {
        List<Ancestor> ancestors = req.getAncestors();
        AbstractProject<?, ?> project = null;
        for (Ancestor ancestor : ancestors) {
            Object object = ancestor.getObject();
            if (object instanceof AbstractProject<?, ?>) {
                project = (AbstractProject<?, ?>) object;
                break;
            }
        }
        this.project = project;
    }
    return super.newInstance(req, formData);
}
项目:uno-choice-plugin    文件:Utils.java   
/**
 * Returns true if this parameter definition is a definition of the given project.
 *
 * @since 1.3
 * @author dynamic-parameter-plugin
 * @param parameterUUID UUID of the project parameter
 * @param project the project to search for this parameter definition.
 * @return {@code true} if the project contains this parameter definition.
 */
private static boolean isParameterDefinitionOf(@Nonnull String parameterUUID, @Nonnull Project<?, ?> project) {
    List<ParameterDefinition> parameterDefinitions = new ArrayList<ParameterDefinition>();
    parameterDefinitions.addAll(getProjectParameterDefinitions(project));
    for (List<ParameterDefinition> params : getBuildWrapperParameterDefinitions(project).values()) {
        parameterDefinitions.addAll(params);
    }
    for (ParameterDefinition pd : parameterDefinitions) {
        if (pd instanceof AbstractUnoChoiceParameter) {
            AbstractUnoChoiceParameter parameterDefinition = (AbstractUnoChoiceParameter) pd;
            String uuid = parameterDefinition.getRandomName();
            if (ObjectUtils.equals(parameterUUID, uuid)) {
                return true;
            }
        }
    }
    return false;
}
项目:uno-choice-plugin    文件:Utils.java   
/**
 * Get parameter definitions associated with {@link BuildWrapper}s of the given {@link Project}.
 * @param project the project for which the parameter definitions should be found
 * @return Map
 */
public static @Nonnull Map<BuildWrapper, List<ParameterDefinition>> getBuildWrapperParameterDefinitions(@Nonnull Project<?, ?> project) {
    final List<BuildWrapper> buildWrappersList = project.getBuildWrappersList();

    final Map<BuildWrapper, List<ParameterDefinition>> result = new LinkedHashMap<BuildWrapper, List<ParameterDefinition>>();

    List<ParameterDefinition> value = new ArrayList<ParameterDefinition>();

    for (BuildWrapper buildWrapper : buildWrappersList) {
        final PropertyDescriptor[] propertyDescriptors;
        try {
            propertyDescriptors = Introspector.getBeanInfo(buildWrapper.getClass()).getPropertyDescriptors();
        } catch (IntrospectionException e) {
            continue;
        }
        for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
            addParameterDefinitionsTo(value, buildWrapper, propertyDescriptor);
        }
        if (!value.isEmpty()) {
            result.put(buildWrapper, value);
            value = new ArrayList<ParameterDefinition>();
        }
    }
    return result.isEmpty() ? Collections.<BuildWrapper, List<ParameterDefinition>> emptyMap() : result;
}
项目:uno-choice-plugin    文件:Utils.java   
private static void addParameterDefinitionsTo(List<ParameterDefinition> target, Object bean, PropertyDescriptor pd) {
    if (ParameterDefinition.class.isAssignableFrom(pd.getPropertyType())) {
        final ParameterDefinition param = read(bean, pd);
        if (param != null) {
            target.add(param);
        }
        return;
    }
    Iterable<?> iterable = null;

    if (Iterable.class.isAssignableFrom(pd.getPropertyType())) {
        iterable = read(bean, pd);
    } else if (Object[].class.isAssignableFrom(pd.getPropertyType())) {
        final Object[] array = read(bean, pd);
        if (array != null)
            iterable = Arrays.asList(array);
    }
    if (iterable == null)
        return;

    for (Object o : iterable) {
        if (ParameterDefinition.class.isInstance(o)) {
            target.add((ParameterDefinition) o);
        }
    }
}
项目:DotCi    文件:ParametersDefinitionPropertyCoverter.java   
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
    if (fromDBObject == null) return null;

    List<DBObject> list = (List) fromDBObject;

    List<ParameterDefinition> parameterDefinitions = new ArrayList<ParameterDefinition>();

    // TODO parsing checks
    for (DBObject dbObject : list) {
        ParameterDefinition definition = (ParameterDefinition) getMapper()
            .fromDBObject(ParameterDefinition.class, dbObject, getMapper().createEntityCache());

        parameterDefinitions.add(definition);
    }

    return new ParametersDefinitionProperty(parameterDefinitions);
}
项目:DotCi    文件:GithubWebhook.java   
private List<ParameterValue> getParametersValues(final Job job, final String branch) {
    final ParametersDefinitionProperty paramDefProp = (ParametersDefinitionProperty) job.getProperty(ParametersDefinitionProperty.class);
    final ArrayList<ParameterValue> defValues = new ArrayList<>();

    for (final ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) {
        if ("BRANCH".equals(paramDefinition.getName())) {
            final StringParameterValue branchParam = new StringParameterValue("BRANCH", branch);
            defValues.add(branchParam);
        } else {
            final ParameterValue defaultValue = paramDefinition.getDefaultParameterValue();
            if (defaultValue != null)
                defValues.add(defaultValue);
        }
    }

    return defValues;
}
项目:DotCi    文件:GithubWebhookTest.java   
@Test
public void should_trigger_build_with_default_parameter_values() throws IOException, InterruptedException {
    final StaplerRequest request = mock(StaplerRequest.class);
    when(request.getParameter("payload")).thenReturn("payload");
    final DynamicProject project = mock(DynamicProject.class);

    final ParameterDefinition branchParameter = mock(ParameterDefinition.class);
    when(branchParameter.getName()).thenReturn("BRANCH");

    final ParameterDefinition secondParameter = mock(ParameterDefinition.class);
    when(branchParameter.getName()).thenReturn("PARAM");
    when(secondParameter.getDefaultParameterValue()).thenReturn(new StringParameterValue("PARAM", "meow"));
    final ParametersDefinitionProperty paramDefinition = mock(ParametersDefinitionProperty.class);
    when(paramDefinition.getParameterDefinitions()).thenReturn(Arrays.asList(branchParameter, secondParameter));
    when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(paramDefinition);

    kickOffBuildTrigger(request, project);

    final ArgumentCaptor<ParametersAction> parametersCaptor = ArgumentCaptor.forClass(ParametersAction.class);
    verify(project).scheduleBuild(eq(0), any(GithubPushPullWebhookCause.class), parametersCaptor.capture());

    final ParametersAction parametersAction = parametersCaptor.getValue();
    Assert.assertTrue(parametersAction.getParameter("PARAM") instanceof StringParameterValue);
    Assert.assertEquals("meow", ((StringParameterValue) parametersAction.getParameter("PARAM")).value);

}
项目:jenkins-inheritance-plugin    文件:InheritanceProject.java   
/**
 * This method dumps the default values of all parameters (even derived
 * ones) into an XML file.
 * <p>
 * Do note that this does not do any expansion,
 * it merely outputs the last default value defined for the given
 * parameter. If you want the full expansion, call
 * {@link #doGetParamExpansionsAsXML()}
 * 
 * @return raw XML string
 */
public String doGetParamDefaultsAsXML() {
    Object obj = onInheritChangeBuffer.get(this, "doGetParamDefaultsAsXML");
    if (obj != null && obj instanceof String) {
        return (String) obj;
    }

    //Fetching a list of unique parameters
    List<ParameterDefinition> defLst =
            this.getParameters(IMode.INHERIT_FORCED);

    LinkedList<ParameterValue> valLst =
            new LinkedList<ParameterValue>();

    //Then, we fetch the expansion of these based on their defaults
    for (ParameterDefinition pd : defLst) {
        ParameterValue pv = pd.getDefaultParameterValue();
        if (pv != null) {
            valLst.add(pv);
        }
    }

    String str = Jenkins.XSTREAM2.toXML(valLst);
    onInheritChangeBuffer.set(this, "doGetParamDefaultsAsXML", str);
    return str;
}
项目:jenkins-inheritance-plugin    文件:InheritableStringParameterReferenceDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (!(defaultValue instanceof StringParameterValue)) {
        //This should never happen
        return super.copyWithDefaultValue(defaultValue);
    }

    StringParameterValue spv = ((StringParameterValue) defaultValue);
    String value = spv.value;
    InheritableStringParameterReferenceDefinition isprd =
            new InheritableStringParameterReferenceDefinition(
                    this.getName(), value
            );
    isprd.setRootProperty(this.getRootProperty());
    return isprd;
}
项目:jenkins-inheritance-plugin    文件:InheritanceParametersDefinitionProperty.java   
public static final List<ParameterDefinition> copyAndSortParametersByName(List<ParameterDefinition> in) {
    //Crate a copy of all PDs in that list
    TreeSet<ParameterDefinition> tree = new TreeSet<ParameterDefinition>(
            new Comparator<ParameterDefinition>() {
                @Override
                public int compare(ParameterDefinition o1, ParameterDefinition o2) {
                    return o1.getName().compareTo(o2.getName());
                }
            }
    );
    for (ParameterDefinition pd : in) {
        // if a parameter definition of type RunParameterDefinition is not configured with a valid project,
        // ParameterDefinition(RunParameterDefinition)#copyWithDefaultValue will raise a NullPointerException
        if (pd instanceof RunParameterDefinition) {
            Job<?, ?> job = ((RunParameterDefinition) pd).getProject();

            if (job != null) {
                tree.add(pd);
            }
        } else {
            tree.add(pd.copyWithDefaultValue(pd.getDefaultParameterValue()));
        }

    }
    return new LinkedList<ParameterDefinition>(tree);
}
项目:jenkins-inheritance-plugin    文件:InheritanceParametersDefinitionProperty.java   
public List<ParameterDefinition> getParameterDefinitionSubset(boolean showHidden) {
    LinkedList<ParameterDefinition> out =
            new LinkedList<ParameterDefinition>();
    //Iterate over all fields
    for (ParameterDefinition pd : this.getParameterDefinitions()) {
        //Checking if value has the getIsHidden field
        Object o = Reflection.invokeIfPossible(pd, "getIsHidden");
        if (o == null || ! (o instanceof Boolean)) {
            //These definitions are treated as non-hidden
            if (!showHidden) {
                out.add(pd);
            }
        } else {
            Boolean isHidden = (Boolean) o;
            if (isHidden && showHidden) {
                out.add(pd);
            } else if (!isHidden && !showHidden) {
                out.add(pd);
            }
        }
    }
    return out;
}
项目:jenkins-inheritance-plugin    文件:InheritanceViewAction.java   
public static Map<String, String> getResolvedBuildParameters(
        InheritanceProject project
) {
    Map<String, String> result = new HashMap<String, String>();

    List<ParameterDefinition> parameters = project.getParameters(
            IMode.INHERIT_FORCED
    );
    for (ParameterDefinition pDef : parameters) {
        ParameterValue pVal = pDef.getDefaultParameterValue();
        if (pVal instanceof StringParameterValue) {
            result.put(
                    pDef.getName(),
                    ((StringParameterValue) pVal).value
            );
        }
    }
    //We do not resolve parameters; as they are most likely not complete anyway
    return result;
}
项目:jenkins-inheritance-plugin    文件:ParameterizedProjectReference.java   
@Override
public AbstractProjectReference newInstance(
        StaplerRequest req, JSONObject formData) throws FormException {
    String targetJob = formData.getString("targetJob");

    String variance = formData.getString("variance");
    FormValidation formValidation = doCheckVariance(formData.getString("variance"));
    if (formValidation.kind != FormValidation.Kind.OK) {
        throw new FormException(
                formValidation.getMessage(),
                "variance"
        );
    }

    Object jParams = formData.get("parameters");
    List<ParameterDefinition> params = 
            ParameterDescriptor.newInstancesFromHeteroList(
                    req, jParams, ParameterDefinition.all()
            );

    return new ParameterizedProjectReference(targetJob, variance, params);
}
项目:jenkins-inheritance-plugin    文件:SimpleParameterizedProjectReference.java   
@DataBoundConstructor
public SimpleParameterizedProjectReference(
        String targetJob,
        List<ParameterDefinition> parameters) {
    super(targetJob);
    InheritanceProject project = this.getProject();
    if (project != null && parameters != null) {
        for (ParameterDefinition pd : parameters) {
            if (pd instanceof InheritableStringParameterDefinition) {
                InheritableStringParameterDefinition ispd =
                        (InheritableStringParameterDefinition) pd;
                ispd.setRootProperty(project.getProperty(
                        InheritanceParametersDefinitionProperty.class
                ));
            }
        }
    }
    if (parameters == null) {
        this.parameters = new LinkedList<ParameterDefinition>();
    } else {
        this.parameters = parameters;
    }
}
项目:jenkins-github-pull-request-comments    文件:GhprcTrigger.java   
private ArrayList<ParameterValue> getDefaultParameters() {
    ArrayList<ParameterValue> values = new ArrayList<ParameterValue>();
    ParametersDefinitionProperty pdp = this.job.getProperty(ParametersDefinitionProperty.class);
    if (pdp != null) {
        for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
            if (pd.getName().equals("sha1"))
                continue;
            values.add(pd.getDefaultParameterValue());
        }
    }
    return values;
}
项目:persistent-parameter-plugin    文件:PersistentChoiceParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue)
{
  if(defaultValue instanceof StringParameterValue)
  {
    StringParameterValue value = (StringParameterValue)defaultValue;
    return new PersistentChoiceParameterDefinition(getName(), getChoices(), value.value, successfulOnly, getDescription());
  }
  else
  {
    return this;
  }
}
项目:persistent-parameter-plugin    文件:PersistentStringParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue)
{
  if(defaultValue instanceof StringParameterValue)
  {
    StringParameterValue value = (StringParameterValue)defaultValue;
    return new PersistentStringParameterDefinition(getName(), value.value, isSuccessfulOnly(), getDescription());
  }
  else
  {
    return this;
  }
}
项目:persistent-parameter-plugin    文件:PersistentBooleanParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue)
{
  if(defaultValue instanceof BooleanParameterValue)
  {
    BooleanParameterValue value = (BooleanParameterValue)defaultValue;
    return new PersistentBooleanParameterDefinition(getName(), value.value, isSuccessfulOnly(), getDescription());
  }
  else
  {
    return this;
  }
}
项目:leroy_jenkins    文件:LeroyPasswordParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (defaultValue instanceof LeroyPasswordParameterValue) {
        LeroyPasswordParameterValue value = (LeroyPasswordParameterValue) defaultValue;
        return new LeroyPasswordParameterDefinition(getName(), Secret.toString(value.getValue()), getDescription());
    } else {
        return this;
    }
}
项目:leroy_jenkins    文件:LeroyChoiceParameterDefinition.java   
@Override
// default value is not passed
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (defaultValue instanceof LeroyStringParameterValue) {
        StringParameterValue value = (LeroyStringParameterValue) defaultValue;
        return new LeroyChoiceParameterDefinition(getName(), getChoices().toArray(new String[]{}), getDescription());
    } else {
        return this;
    }
}
项目:leroy_jenkins    文件:LeroyStringParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (defaultValue instanceof LeroyStringParameterValue) {
        LeroyStringParameterValue value = (LeroyStringParameterValue) defaultValue;
        return new StringParameterDefinition(getName(), value.value, getDescription());
    } else {
        return this;
    }
}
项目:ghprb-copy    文件:GhprbTrigger.java   
private ArrayList<ParameterValue> getDefaultParameters() {
    ArrayList<ParameterValue> values = new ArrayList<ParameterValue>();
    ParametersDefinitionProperty pdp = this.job.getProperty(ParametersDefinitionProperty.class);
    if (pdp != null) {
        for(ParameterDefinition pd :  pdp.getParameterDefinitions()) {
            if (pd.getName().equals("sha1"))
                continue;
            values.add(pd.getDefaultParameterValue());
        }
    }
    return values;
}
项目:p4-jenkins    文件:ReviewAction.java   
/**
 * Jelly Method
 *
 * @return List of Parameters
 */
public List<StringParameterValue> getAvailableParameters() {
    List<StringParameterValue> stringParameters = new ArrayList<StringParameterValue>();

    for (ParameterDefinition parameterDefinition : getParameterDefinitions()) {
        StringParameterValue stringParameter = new StringParameterValue(parameterDefinition.getName(),
                parameterDefinition.getDescription());
        stringParameters.add(stringParameter);
    }

    return stringParameters;
}
项目:p4-jenkins    文件:ReviewAction.java   
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {

        project.checkPermission(AbstractProject.BUILD);

        List<ParameterValue> values = new ArrayList<ParameterValue>();
        List<ParameterDefinition> defs = new ArrayList<ParameterDefinition>();

        Enumeration<?> names = req.getParameterNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            defs.add(new StringParameterDefinition(name, null));
        }

        for (ParameterDefinition d : defs) {
            StringParameterValue value = (StringParameterValue) d.createValue(req);
            if (value != null && value.value != null && !value.value.isEmpty()) {
                values.add(value);
            }
        }

        // Schedule build
        TimeDuration delay = new TimeDuration(project.getQuietPeriod());
        CauseAction cause = new CauseAction(new Cause.UserIdCause());

        List<ParameterValue> internalParams = extractAndRemoveInternalParameters(values);
        ParametersAction params = new SafeParametersAction(values, internalParams);

        Jenkins j = Jenkins.getInstance();
        if (j != null) {
            Queue queue = j.getQueue();
            queue.schedule(project, delay.getTime(), params, cause);

            // send the user back to the job top page.
            rsp.sendRedirect("../");
        }
    }
项目:p4-jenkins    文件:ReviewAction.java   
private List<ParameterDefinition> getParameterDefinitions() {
    List<ParameterDefinition> swarm = new ArrayList<ParameterDefinition>();

    // Swarm parameters
    swarm.add(new StringParameterDefinition(ReviewProp.REVIEW.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.CHANGE.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.STATUS.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.PASS.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.FAIL.getProp(), null));

    // Custom parameters
    swarm.add(new StringParameterDefinition(ReviewProp.LABEL.toString(), null));

    return swarm;
}
项目:uno-choice-plugin    文件:Utils.java   
/**
 * Get the parameter definitions for the given project.
 *
 * @since 1.3
 * @author dynamic-parameter-plugin
 * @param project the project for which the parameter definitions should be found
 * @return parameter definitions or an empty list
 */
public static @Nonnull List<ParameterDefinition> getProjectParameterDefinitions(@Nonnull Project<?, ?> project) {
    ParametersDefinitionProperty parametersDefinitionProperty = project.getProperty(ParametersDefinitionProperty.class);
    if (parametersDefinitionProperty != null) {
        List<ParameterDefinition> parameterDefinitions = parametersDefinitionProperty.getParameterDefinitions();
        if (parameterDefinitions != null) {
            return parameterDefinitions;
        }
    }
    return Collections.emptyList();
}
项目:DotCi    文件:ParametersDefinitionPropertyCoverter.java   
@Override
public Object encode(Object value, MappedField optionalExtraInfo) {
    if (value == null) return null;

    ParametersDefinitionProperty parametersDefinitionProperty = (ParametersDefinitionProperty) value;

    BasicDBList parameters = new BasicDBList();
    for (ParameterDefinition definition : parametersDefinitionProperty.getParameterDefinitions()) {
        parameters.add(getMapper().toDBObject(definition));
    }

    return parameters;
}
项目:ccr-parameter-plugin    文件:DynamicConfigurationDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (defaultValue instanceof DynamicConfigurationValue) {
        DynamicConfigurationValue value = (DynamicConfigurationValue)defaultValue;
        return new DynamicConfigurationDefinition(value.getName(), value.getClient(), value.getTarget(),
            ccrVariables);
    } else {
        return this;
    }
}
项目:jenkins-inheritance-plugin    文件:InheritanceProject.java   
/**
 * This method dumps the full expansion of all parameters (even derived
 * ones) based on their default values into an XML file.
 * <p>
 * If you only want the default values of the last definition of each
 * parameter, use {@link #doGetParamDefaultsAsXML()}
 * 
 * @return raw XML string
 */
public String doGetParamExpansionsAsXML() {
    /*
    Object obj = onInheritChangeBuffer.get(this, "doGetParamExpansionsAsXML");
    if (obj != null && obj instanceof String) {
        return (String) obj;
    }
    */

    //Fetching a list of unique parameters
    List<ParameterDefinition> defLst = this.getParameters(IMode.INHERIT_FORCED);

    LinkedList<ParameterValue> valLst =
            new LinkedList<ParameterValue>();

    //Then, we fetch the expansion of these based on their defaults
    for (ParameterDefinition pd : defLst) {
        ParameterValue pv = null;
        if (pd instanceof InheritableStringParameterDefinition) {
            InheritableStringParameterDefinition ispd =
                    (InheritableStringParameterDefinition) pd;
            pv = ispd.createValue(ispd.getDefaultValue());
        } else {
            pv = pd.getDefaultParameterValue();
        }
        if (pv != null) {
            valLst.add(pv);
        }
    }

    String str = Jenkins.XSTREAM2.toXML(valLst);
    //onInheritChangeBuffer.set(this, "doGetParamExpansionsAsXML", str);
    return str;
}
项目:jenkins-inheritance-plugin    文件:InheritanceProject.java   
public List<ParameterDefinition> getParameters(IMode mode) {
    ParametersDefinitionProperty pdp =
            this.getProperty(ParametersDefinitionProperty.class, mode);
    if (pdp == null) {
        return new LinkedList<ParameterDefinition>();
    }
    return pdp.getParameterDefinitions();
}
项目:jenkins-inheritance-plugin    文件:InheritanceProject.java   
private List<ScopeEntry> getFullParameterScope() {
    //Fetching the correct definition property
    ParametersDefinitionProperty pdp = this.getProperty(
            ParametersDefinitionProperty.class, IMode.INHERIT_FORCED
    );
    if (pdp == null) {
        //No parameters set, so we return an empty list
        return Collections.emptyList();
    }

    //Checking if it is a fully scoped inheritance-aware one; if yes, we
    //fetch the full scope of parameters.
    List<ScopeEntry> fullScope = null;
    if (pdp instanceof InheritanceParametersDefinitionProperty) {
        InheritanceParametersDefinitionProperty ipdp =
                (InheritanceParametersDefinitionProperty) pdp;
        fullScope = ipdp.getAllScopedParameterDefinitions();
    } else {
        String ownerName = (pdp.getOwner() != null)
                ? pdp.getOwner().getFullName() : "";
        fullScope = new LinkedList<ScopeEntry>();
        for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
            fullScope.add(new ScopeEntry(ownerName, pd));
        }
    }

    if (fullScope != null) {
        return fullScope;
    } else {
        return Collections.emptyList();
    }
}
项目:jenkins-inheritance-plugin    文件:InheritanceProject.java   
public String getSVGDetail() {
    List<ParameterDefinition> pLst = this.getParameters(IMode.LOCAL_ONLY);
    if (pLst == null) {
        return "";
    }
    StringBuilder b = new StringBuilder();
    for (ParameterDefinition pd : pLst) {
        if (pd == null) { continue; }
        b.append(pd.getName());
        ParameterValue pv = pd.getDefaultParameterValue();
        if (pv != null && pv instanceof StringParameterValue) {
            b.append(": ");
            b.append(((StringParameterValue)pv).value);
        }
        b.append('\n');
    }

    if (b.length() > 0) {
        b.append("\r\n");
    }

    List<Builder> builders = this.getBuilders();
    String str = (builders == null || builders.size() != 1) ? "steps" : "step";
    int num = (builders == null) ? 0 : builders.size();
    b.append(String.format(
            "%d build %s\n", num, str
    ));

    DescribableList<Publisher, Descriptor<Publisher>> pubs = this.getPublishersList();
    str = (pubs == null || pubs.size() != 1) ? "publishers" : "publisher";
    num = (pubs == null) ? 0 : pubs.size();
    b.append(String.format(
            "%d %s", num, str
    ));



    return b.toString();
}
项目:jenkins-inheritance-plugin    文件:InheritanceParametersDefinitionProperty.java   
public InheritanceParametersDefinitionProperty(
        AbstractProject<?,?> owner,
        List<ParameterDefinition> parameterDefinitions) {
    super(copyAndSortParametersByName(parameterDefinitions));

    //Save the final owner that created this IPDP
    this.owner = owner;

    //Applying the current owner and this object to the PDs, if necessary.
    this.applyOwnerToDefinitions();
}
项目:jenkins-inheritance-plugin    文件:InheritanceParametersDefinitionProperty.java   
private void applyOwnerToDefinitions() {
    for (ParameterDefinition pd : this.getParameterDefinitions()) {
        if (!(pd instanceof InheritableStringParameterDefinition)) {
            continue;
        }
        InheritableStringParameterDefinition ispd =
                (InheritableStringParameterDefinition) pd;
        ispd.setRootProperty(this);
    }
}
项目:jenkins-inheritance-plugin    文件:InheritableStringParameterDefinition.java   
/**
 * This function creates a new {@link ParameterDefinition} that carries
 * the given value as the default value.
 * <p>
 * Do note that due to inheritance, the final default value may be derived
 * from multiple projects/parents. Such a parameter may be derived either
 * as: Fixed, Overwritable or Extensible.
 * <p>
 * The first and second one are trivial cases where the default value is
 * used as is. The problem lies in dealing with an extensible parameter, as
 * in that case a prefix of the given default value may need to be stripped.
 * <p>
 * <b>Do note</b> that this is automatically done when you call
 * {@link #getDerivedValue(String, boolean)}, but <b>not</b> when you call
 * {@link #produceDerivedValue(String)}. If you need to access this
 * behaviour from some place else, call {@link #stripInheritedPrefixFromValue()}
 */
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (!(defaultValue instanceof StringParameterValue)) {
        //This should never happen
        return super.copyWithDefaultValue(defaultValue);
    }

    StringParameterValue spv = ((StringParameterValue) defaultValue);
    String value = spv.value;

    //Creating the PD to return
    InheritableStringParameterDefinition ispd =
        new InheritableStringParameterDefinition(
            getName(),
            value,
            getDescription(),
            this.getInheritanceModeAsVar(),
            this.getMustHaveDefaultValue(),
            this.getMustBeAssigned(),
            this.getWhitespaceModeAsVar(),
            this.getIsHidden()
        );
    ispd.variance = this.variance;
    ispd.setRootProperty(this.rootProperty);
    return ispd;
}
项目:jenkins-inheritance-plugin    文件:ParameterizedProjectReference.java   
public ParameterizedProjectReference(String targetJob, String variance,
        List<ParameterDefinition> parameters) {
    super(targetJob, parameters);

    if (StringUtils.isNotBlank(variance)) {
        this.variance = variance.trim();
    }
}