Skip to content

Commit

Permalink
Merge pull request #62 from jglick/dropdownDescriptorSelector-JENKINS…
Browse files Browse the repository at this point in the history
…-28011

[JENKINS-28011] Using the standard f:dropdownDescriptorSelector
  • Loading branch information
ikedam committed Apr 25, 2015
2 parents d574c00 + 3602ed8 commit ff6073c
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -26,7 +26,6 @@
import com.thoughtworks.xstream.converters.UnmarshallingContext;

import hudson.AbortException;
import hudson.DescriptorExtensionList;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand Down Expand Up @@ -268,10 +267,15 @@ public String getParameters() {
return parameters;
}

@Deprecated
public BuildSelector getBuildSelector() {
return selector;
}

public BuildSelector getSelector() {
return selector;
}

public String getFilter() {
return filter;
}
Expand Down Expand Up @@ -523,9 +527,6 @@ public String getDisplayName() {
return Messages.CopyArtifact_DisplayName();
}

public DescriptorExtensionList<BuildSelector,Descriptor<BuildSelector>> getBuildSelectors() {
return Hudson.getInstance().<BuildSelector,Descriptor<BuildSelector>>getDescriptorList(BuildSelector.class);
}
}

// Listen for project renames and update property here if needed.
Expand Down
Expand Up @@ -38,8 +38,8 @@ public class StatusBuildSelector extends BuildSelector {
private Boolean stable;

@DataBoundConstructor
public StatusBuildSelector(boolean stableOnly) {
this.stable = stableOnly ? Boolean.TRUE : null;
public StatusBuildSelector(boolean stable) {
this.stable = stable ? Boolean.TRUE : null;
}

public boolean isStable() {
Expand Down
Expand Up @@ -95,8 +95,8 @@ public boolean isForGlobalSetting() {
private final UpstreamFilterStrategy upstreamFilterStrategy;

@DataBoundConstructor
public TriggeredBuildSelector(boolean fallback, UpstreamFilterStrategy upstreamFilterStrategy) {
this.fallbackToLastSuccessful = fallback ? Boolean.TRUE : null;
public TriggeredBuildSelector(boolean fallbackToLastSuccessful, UpstreamFilterStrategy upstreamFilterStrategy) {
this.fallbackToLastSuccessful = fallbackToLastSuccessful ? Boolean.TRUE : null;
this.upstreamFilterStrategy = upstreamFilterStrategy;
}

Expand Down
Expand Up @@ -26,8 +26,7 @@ THE SOFTWARE.
<f:entry title="${%Project name}" field="projectName">
<f:editableComboBox items="${app.topLevelItemNames}" clazz="setting-input"/>
</f:entry>
<ca:selectorList currentSelector="${instance.buildSelector}"
name="selector" title="${%Which build}"/>
<f:dropdownDescriptorSelector field="selector" title="${%Which build}"/>
<f:entry title="${%Artifacts to copy}" field="filter">
<f:textbox/>
</f:entry>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright 2015 Jesse Glick.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
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"/>
Expand Up @@ -23,8 +23,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="${%Parameter Name}" help="/plugin/copyartifact/help-parameterName.html">
<f:textbox clazz="required" name="parameterName" value="${selector.parameterName}"
default="BUILD_SELECTOR"/>
<f:entry field="parameterName" title="${%Parameter Name}">
<f:textbox clazz="required" default="BUILD_SELECTOR"/>
</f:entry>
</j:jelly>
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright 2015 Jesse Glick.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
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"/>
Expand Up @@ -23,7 +23,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="${%Build number}" help="/plugin/copyartifact/help-specificBuild.html">
<f:textbox name="buildNumber" value="${selector.buildNumber}"/>
<f:entry field="buildNumber" title="${%Build number}">
<f:textbox/>
</f:entry>
</j:jelly>
File renamed without changes.
Expand Up @@ -23,8 +23,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="">
<f:checkbox name="stableOnly" checked="${selector.isStable()}"/>
<label class="attach-previous">${%Stable build only}</label>
<f:entry field="stable">
<f:checkbox title="${%Stable build only}"/>
</f:entry>
</j:jelly>
Expand Up @@ -23,9 +23,8 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="">
<f:checkbox name="fallback" checked="${selector.isFallbackToLastSuccessful()}"/>
<label class="attach-previous">${%Use "Last successful build" as fallback}</label>
<f:entry field="fallbackToLastSuccessful">
<f:checkbox title="${%Use &quot;Last successful build&quot; as fallback}"/>
</f:entry>
<f:advanced>
<f:entry field="upstreamFilterStrategy" title="${%Which for multiple upstream}">
Expand Down
Expand Up @@ -59,7 +59,7 @@ public void testParameter() throws Exception {
wc.setPrintContentOnFailingStatusCode(false);
HtmlForm form = wc.getPage(job, "build").getFormByName("parameters");
form.getSelectByName("").getOptionByText("Specific build").setSelected(true);
form.getInputByName("buildNumber").setValueAttribute("6");
form.getInputByName("_.buildNumber").setValueAttribute("6");
submit(form);
Queue.Item q = hudson.getQueue().getItem(job);
if (q != null) q.getFuture().get();
Expand Down
Expand Up @@ -1160,7 +1160,6 @@ public void testFieldValidation() throws Exception {
// Other descriptor methods
assertTrue(descriptor.isApplicable(null));
assertTrue(descriptor.getDisplayName().length() > 0);
assertTrue(descriptor.getBuildSelectors().size() > 0);
}

@LocalData
Expand Down

0 comments on commit ff6073c

Please sign in to comment.