Skip to content
Permalink
Browse files

Merge pull request #63 from ikedam/feature/JENKINS-28094_RemoveOwnTaglib

[JENKINS-28094] Removed ca:selectorList
  • Loading branch information...
ikedam committed May 8, 2015
2 parents ff6073c + 4e5cd11 commit 406248600e3b8c0669308ea68fd7d991741a1d3b
@@ -23,6 +23,9 @@
*/
package hudson.plugins.copyartifact;

import java.util.List;

import jenkins.model.Jenkins;
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.model.Descriptor;
@@ -35,6 +38,10 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;

/**
* @author Alan Harder
*/
@@ -90,6 +97,35 @@ public String getDisplayName() {
public DescriptorExtensionList<BuildSelector,Descriptor<BuildSelector>> getBuildSelectors() {
return Hudson.getInstance().<BuildSelector,Descriptor<BuildSelector>>getDescriptorList(BuildSelector.class);
}

/**
* @return {@link BuildSelector}s available for BuildSelectorParameter.
*/
public List<Descriptor<BuildSelector>> getAvailableBuildSelectorList() {
return Lists.newArrayList(Collections2.filter(
Jenkins.getInstance().getDescriptorList(BuildSelector.class),
new Predicate<Descriptor<BuildSelector>>() {
public boolean apply(Descriptor<BuildSelector> input) {
return !"ParameterizedBuildSelector".equals(input.clazz.getSimpleName());
};
}
));
}

@Override
public String getHelpFile(String fieldName) {
if ("defaultSelector".equals(fieldName) || "parameter".equals(fieldName)) {
// Display the help file of `Copyartifact#getSelector` ("which build" field)
// for `defaultSelector` ("Default Selector" field) in project configuration pages
// and the value of build parameter ("Build selector for Copy Artifact" field)
// in "This build requires parameters" pages.
Descriptor<?> d = Jenkins.getInstance().getDescriptor(CopyArtifact.class);
if (d != null) {
return d.getHelpFile("selector");
}
}
return super.getHelpFile(fieldName);
}
}

private static final XStream2 XSTREAM = new XStream2();
@@ -497,7 +497,7 @@ private boolean perform(Run src, Run<?,?> dst, String expandedFilter, String exp
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckProjectName(
@AncestorInPath AbstractProject anc, @QueryParameter String value) {
@AncestorInPath Job<?,?> anc, @QueryParameter String value) {
// Require CONFIGURE permission on this project
if (!anc.hasPermission(Item.CONFIGURE)) return FormValidation.ok();
FormValidation result;
@@ -515,7 +515,7 @@ else if (value.indexOf('$') >= 0)
else
result = FormValidation.error(
hudson.tasks.Messages.BuildTrigger_NoSuchProject(
value, AbstractProject.findNearest(value).getName()));
value, Items.findNearest(Job.class, value, anc.getParent()).getName()));
return result;
}

@@ -22,12 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form" xmlns:ca="/hudson/plugins/copyartifact">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="${%Name}" field="name" help="/help/parameter/name.html">
<f:textbox/>
</f:entry>
<ca:selectorList currentSelector="${instance.defaultSelector}"
name="defaultSelector" title="${%Default Selector}" omit="ParameterizedBuildSelector"/>
<f:dropdownDescriptorSelector field="defaultSelector"
title="${%Default Selector}" descriptors="${descriptor.availableBuildSelectorList}" />
<f:entry title="${%Description}" field="description" help="/help/parameter/description.html">
<f:textarea/>
</f:entry>
@@ -22,10 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:ca="/hudson/plugins/copyartifact">
<ca:selectorList currentSelector="${it.defaultSelector}" descriptor="${it.descriptor}"
name="parameter" title="${it.name}" description="${it.description}"
omit="ParameterizedBuildSelector">
<tr><td><input type="hidden" name="name" value="${it.name}"/></td></tr>
</ca:selectorList>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<j:scope>
<j:set var="descriptor" value="${it.descriptor}" /> <!-- this enables displaying the help file. -->
<f:dropdownDescriptorSelector field="parameter"
title="${it.name}" description="${it.description}"
default="${it.defaultSelector}"
descriptors="${it.descriptor.availableBuildSelectorList}">
<j:if test="${dropdownListMode=='generateEntries'}">
<tr><td><input type="hidden" name="name" value="${it.name}"/></td></tr>
</j:if>
</f:dropdownDescriptorSelector>
</j:scope>
</j:jelly>
@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form" xmlns:ca="/hudson/plugins/copyartifact">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="${%Project name}" field="projectName">
<f:editableComboBox items="${app.topLevelItemNames}" clazz="setting-input"/>
</f:entry>

This file was deleted.

Oops, something went wrong.
@@ -91,4 +91,15 @@ public void testParameter() throws Exception {
while (job.getLastBuild().isBuilding()) Thread.sleep(100);
assertEquals("<SavedBuildSelector/>", ceb.getEnvVars().get("SELECTOR"));
}

public void testConfiguration() throws Exception {
BuildSelectorParameter expected = new BuildSelectorParameter("SELECTOR", new StatusBuildSelector(true), "foo");
FreeStyleProject job = createFreeStyleProject();
job.addProperty(new ParametersDefinitionProperty(expected));
job.save();

job = configRoundtrip(job);
BuildSelectorParameter actual = (BuildSelectorParameter)job.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("SELECTOR");
assertEqualDataBoundBeans(expected, actual);
}
}

0 comments on commit 4062486

Please sign in to comment.
You can’t perform that action at this time.