use of hudson.model.Descriptor in project workflow-cps-plugin by jenkinsci.
the class StepDescriptorCache method getDescriptor.
@CheckForNull
public StepDescriptor getDescriptor(String descriptorId) {
if (descriptorId == null) {
return null;
}
StepDescriptor v = store.get(descriptorId);
if (v != null) {
return v;
} else {
Jenkins j = Jenkins.getActiveInstance();
Descriptor d = j.getDescriptor(descriptorId);
if (d instanceof StepDescriptor) {
store.put(descriptorId, (StepDescriptor) d);
return (StepDescriptor) d;
}
return null;
}
}
use of hudson.model.Descriptor in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfigurator method getExtensionPoint.
public Class getExtensionPoint() {
final Descriptor descriptor = getDescriptor();
if (descriptor != null) {
// detect common pattern DescriptorImpl extends Descriptor<ExtensionPoint>
final Type superclass = descriptor.getClass().getGenericSuperclass();
if (superclass instanceof ParameterizedType) {
final ParameterizedType genericSuperclass = (ParameterizedType) superclass;
Type type = genericSuperclass.getActualTypeArguments()[0];
if (type instanceof ParameterizedType) {
type = ((ParameterizedType) type).getRawType();
}
if (type instanceof Class) {
return (Class) type;
}
}
}
return super.getExtensionPoint();
}
use of hudson.model.Descriptor in project promoted-builds-plugin by jenkinsci.
the class ManualConditionTest method addPromotionProcess.
private PromotionProcess addPromotionProcess(AbstractProject<?, ?> owner, String name) throws Exception {
ExtensionList<Descriptor> list = j.jenkins.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(owner);
owner.addProperty(base);
return base.addProcess(name);
}
use of hudson.model.Descriptor in project promoted-builds-plugin by jenkinsci.
the class ManualConditionTest method testManualPromotionProcess.
@Test
public void testManualPromotionProcess() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
ExtensionList<Descriptor> list = j.jenkins.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess foo = base.addProcess("foo");
ManualCondition condition = new ManualCondition();
condition.getParameterDefinitions().add(new StringParameterDefinition("bogus_string_param_1", "bogus_value_1", "Bog parameter"));
condition.getParameterDefinitions().add(new StringParameterDefinition("bogus_string_param_2", "bogus_value_2", "Bog parameter"));
foo.conditions.add(condition);
FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
// promote a build
List<ParameterValue> paramValues = condition.createDefaultValues();
// try to add duplicate values
paramValues.addAll(condition.createDefaultValues());
j.assertBuildStatusSuccess(condition.approve(b1, foo, paramValues));
ManualApproval manualApproval = b1.getAction(ManualApproval.class);
assertNotNull(manualApproval);
PromotedBuildAction statuses = b1.getAction(PromotedBuildAction.class);
assertNotNull(statuses);
assertNotNull(statuses.getPromotions());
assertFalse(statuses.getPromotions().isEmpty());
}
use of hudson.model.Descriptor in project promoted-builds-plugin by jenkinsci.
the class ManualConditionBug22005 method testPromotionProcess.
@Test
public void testPromotionProcess() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
ExtensionList<Descriptor> list = j.jenkins.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess prom0 = createPromotionProcess(base, "PROM0");
ManualCondition prom0Condition = prom0.conditions.get(ManualCondition.class);
PromotionProcess prom1 = createPromotionProcess(base, "PROM1");
ManualCondition prom1Condition = prom1.conditions.get(ManualCondition.class);
PromotionProcess prom2 = createPromotionProcess(base, "PROM2");
ManualCondition prom2Condition = prom2.conditions.get(ManualCondition.class);
FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
Promotion p0b1 = j.assertBuildStatusSuccess(prom0Condition.approve(b1, prom0));
assertEquals(2, p0b1.getParameterValues().size());
assertEquals(2, p0b1.getParameterDefinitionsWithValue().size());
Promotion p1b1 = j.assertBuildStatusSuccess(prom1Condition.approve(b1, prom1));
assertEquals(2, p1b1.getParameterValues().size());
assertEquals(2, p1b1.getParameterDefinitionsWithValue().size());
Promotion p2b1 = j.assertBuildStatusSuccess(prom2Condition.approve(b1, prom2));
assertEquals(2, p2b1.getParameterValues().size());
assertEquals(2, p2b1.getParameterDefinitionsWithValue().size());
List<ManualApproval> approvals = b1.getActions(ManualApproval.class);
assertEquals(3, approvals.size());
PromotedBuildAction promBuildAction = b1.getAction(PromotedBuildAction.class);
List<Status> statuses = promBuildAction.getPromotions();
assertEquals(3, statuses.size());
for (Status status : statuses) {
Promotion lastBuild = status.getLast();
List<ParameterDefinition> lastBuildParameters = lastBuild.getParameterDefinitionsWithValue();
assertEquals(2, lastBuildParameters.size());
}
}
Aggregations