本文整理汇总了Java中hudson.model.JobPropertyDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java JobPropertyDescriptor类的具体用法?Java JobPropertyDescriptor怎么用?Java JobPropertyDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JobPropertyDescriptor类属于hudson.model包,在下文中一共展示了JobPropertyDescriptor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperties
import hudson.model.JobPropertyDescriptor; //导入依赖的package包/类
public Map<JobPropertyDescriptor, JobProperty<? super InheritanceProject>> getProperties(IMode mode) {
List<JobProperty<? super InheritanceProject>> lst = this.getAllProperties(mode);
if (lst == null || lst.isEmpty()) {
return Collections.emptyMap();
}
HashMap<JobPropertyDescriptor, JobProperty<? super InheritanceProject>> map =
new HashMap<JobPropertyDescriptor, JobProperty<? super InheritanceProject>>();
for (JobProperty<? super InheritanceProject> prop : lst) {
map.put(prop.getDescriptor(), prop);
}
return map;
}
示例2: testSaveParameters
import hudson.model.JobPropertyDescriptor; //导入依赖的package包/类
/**
* Test persisting jobs with parameters.
*
* @throws Exception in Jenkins rule
*/
@Test
public void testSaveParameters() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
GroovyScript scriptParam001 = new GroovyScript(new SecureGroovyScript(SCRIPT_PARAM001, false, null),
new SecureGroovyScript(SCRIPT_FALLBACK_PARAM001, false, null));
ChoiceParameter param001 = new ChoiceParameter("param001", "param001 description", "random-name",
scriptParam001, AbstractUnoChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, true, 1);
GroovyScript scriptParam002 = new GroovyScript(new SecureGroovyScript(SCRIPT_PARAM002, false, null),
new SecureGroovyScript(SCRIPT_FALLBACK_PARAM002, false, null));
CascadeChoiceParameter param002 = new CascadeChoiceParameter("param002", "param002 description", "random-name",
scriptParam002, AbstractUnoChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, "param001", true, 1);
ParametersDefinitionProperty param001Def = new ParametersDefinitionProperty(
Arrays.<ParameterDefinition>asList(param001, param002));
project.addProperty(param001Def);
QueueTaskFuture<FreeStyleBuild> future = project.scheduleBuild2(0);
FreeStyleBuild build = future.get();
// even though the cascaded parameter will fail to evaluate, we should
// still get a success here.
assertEquals(Result.SUCCESS, build.getResult());
XmlFile configXml = project.getConfigFile();
FreeStyleProject reReadProject = (FreeStyleProject) configXml.read();
int found = 0;
for (Entry<JobPropertyDescriptor, JobProperty<? super FreeStyleProject>> entry : reReadProject.getProperties()
.entrySet()) {
JobProperty<? super FreeStyleProject> jobProperty = entry.getValue();
if (jobProperty instanceof ParametersDefinitionProperty) {
ParametersDefinitionProperty paramDef = (ParametersDefinitionProperty) jobProperty;
List<ParameterDefinition> parameters = paramDef.getParameterDefinitions();
for (ParameterDefinition parameter : parameters) {
if (parameter instanceof AbstractScriptableParameter) {
found++;
AbstractScriptableParameter choiceParam = (AbstractScriptableParameter) parameter;
String scriptText = ((GroovyScript) choiceParam.getScript()).getScript().getScript();
String fallbackScriptText = ((GroovyScript) choiceParam.getScript()).getFallbackScript()
.getScript();
assertTrue("Found an empty script!", StringUtils.isNotBlank(scriptText));
assertTrue("Found an empty fallback script!", StringUtils.isNotBlank(fallbackScriptText));
if (parameter.getName().equals("param001")) {
assertEquals(SCRIPT_PARAM001, scriptText);
assertEquals(SCRIPT_FALLBACK_PARAM001, fallbackScriptText);
} else {
assertEquals(SCRIPT_PARAM002, scriptText);
assertEquals(SCRIPT_FALLBACK_PARAM002, fallbackScriptText);
}
}
}
}
}
// We have two parameters before saving. We must have two now.
assertEquals("Didn't find all parameters after persisting xml", 2, found);
}
示例3: getJobPropertyDescriptors
import hudson.model.JobPropertyDescriptor; //导入依赖的package包/类
public static List<JobPropertyDescriptor> getJobPropertyDescriptors(
Class<? extends Job> clazz,
boolean filterIsExcluding, String... filters) {
List<JobPropertyDescriptor> out = new ArrayList<JobPropertyDescriptor>();
//JobPropertyDescriptor.getPropertyDescriptors(clazz);
List<JobPropertyDescriptor> allDesc = Functions.getJobPropertyDescriptors(clazz);
for (JobPropertyDescriptor desc : allDesc) {
String dName = desc.getClass().getName();
if (filters.length > 0) {
boolean matched = false;
if (filters != null) {
for (String filter : filters) {
if (dName.contains(filter)) {
matched = true;
break;
}
}
}
if (filterIsExcluding && matched) {
continue;
} else if (!filterIsExcluding && !matched) {
continue;
}
}
//The class has survived the filter
out.add(desc);
}
//At last, we make sure to sort the fields by full name; to ensure
//that properties from the same package/plugin are next to each other
Collections.sort(out, new Comparator<JobPropertyDescriptor>() {
@Override
public int compare(JobPropertyDescriptor o1,
JobPropertyDescriptor o2) {
String c1 = o1.getClass().getName();
String c2 = o2.getClass().getName();
return c1.compareTo(c2);
}
});
return out;
}
示例4: getDescriptor
import hudson.model.JobPropertyDescriptor; //导入依赖的package包/类
@Override
public JobPropertyDescriptor getDescriptor() {
return DESCRIPTOR;
}
示例5: getDescriptor
import hudson.model.JobPropertyDescriptor; //导入依赖的package包/类
/**
* We need to override this method do prevent Jenkins from trying to
* register this class as a "real" property worthy of inclusion in the
* configuration view.
* <p>
* This is necessary, because this class is only a pure wrapper around
* {@link ParametersDefinitionProperty} and does not own any properties
* that need to be stored separately.
* <p>
* Unfortunately; not defining a Descriptor at all would lead to this
* class not being able to completely wrap the
* {@link ParametersDefinitionProperty} class.
*/
@Override
public JobPropertyDescriptor getDescriptor() {
//return super.getDescriptor();
return (JobPropertyDescriptor) Jenkins.getInstance().getDescriptorOrDie(
ParametersDefinitionProperty.class
);
}
开发者ID:i-m-c,项目名称:jenkins-inheritance-plugin,代码行数:21,代码来源:InheritanceParametersDefinitionProperty.java