Skip to content
Permalink
Browse files
[FIXED JENKINS-13795] NPE when configuring flexible publish in new job
  • Loading branch information
bap2000 committed Jul 3, 2012
1 parent 0341a1e commit 2c906b84b1fed6e1b0781cb98cadf6579478f592
Showing 2 changed files with 11 additions and 5 deletions.
@@ -40,10 +40,10 @@
import org.jenkins_ci.plugins.run_condition.RunCondition;
import org.jenkins_ci.plugins.run_condition.core.AlwaysRun;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Stapler;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class ConditionalPublisher implements Describable<ConditionalPublisher> {
@@ -118,10 +118,11 @@ public RunCondition.RunConditionDescriptor getDefaultRunCondition() {
return Hudson.getInstance().getDescriptorByType(AlwaysRun.AlwaysRunDescriptor.class);
}

public List<? extends Descriptor<? extends BuildStep>> getAllowedPublishers() {
final AbstractProject project = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
public List<? extends Descriptor<? extends BuildStep>> getAllowedPublishers(Object project) {
if (!(project instanceof AbstractProject))
return Collections.singletonList(getDefaultPublisher());
return Hudson.getInstance().getDescriptorByType(FlexiblePublisher.FlexiblePublisherDescriptor.class).getPublisherLister()
.getAllowedPublishers(project);
.getAllowedPublishers((AbstractProject) project);
}

public Descriptor<? extends BuildStep> getDefaultPublisher() {
@@ -26,6 +26,10 @@

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<j:scope>
<!-- it appears that the min var from the repeatable in flexible pub is leaking -->
<!-- and remove does not work! <j:remove var="minimum"/> -->
<j:set var="minimum" value="0"/>
<f:entry>
<f:dropdownDescriptorSelector title="${%runCondition}" field="condition" descriptors="${descriptor.runConditions}"
default="${descriptor.defaultRunCondition}"/>
@@ -37,8 +41,9 @@
</f:entry>
</f:advanced>
<f:entry>
<f:dropdownDescriptorSelector title="${%publisher}" field="publisher" descriptors="${descriptor.allowedPublishers}"
<f:dropdownDescriptorSelector title="${%publisher}" field="publisher" descriptors="${descriptor.getAllowedPublishers(it)}"
default="${descriptor.defaultPublisher}"/>
</f:entry>
</j:scope>

</j:jelly>

0 comments on commit 2c906b8

Please sign in to comment.