Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-15920] Add boolean parameter option
Add a parameter item to allow boolean parameters to be passed to down stream jobs
- Loading branch information
Showing
5 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/main/java/hudson/plugins/parameterizedtrigger/BooleanParameterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013, Chris Johnson | ||
* | ||
* 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. | ||
*/ | ||
package hudson.plugins.parameterizedtrigger; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Describable; | ||
import hudson.model.Descriptor; | ||
import hudson.model.Hudson; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* | ||
* @author Chris Johnson | ||
*/ | ||
public class BooleanParameterConfig implements Describable<BooleanParameterConfig>{ | ||
|
||
private final String name; | ||
private final boolean value; | ||
|
||
@DataBoundConstructor | ||
public BooleanParameterConfig(String name, boolean value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
public boolean getValue() { | ||
return value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Descriptor<BooleanParameterConfig> getDescriptor() { | ||
return Hudson.getInstance().getDescriptorOrDie(getClass()); | ||
} | ||
|
||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<BooleanParameterConfig> { | ||
@Override | ||
public String getDisplayName() { | ||
return ""; // unused | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/hudson/plugins/parameterizedtrigger/BooleanParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013, Chris Johnson | ||
* | ||
* 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. | ||
*/ | ||
package hudson.plugins.parameterizedtrigger; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.Action; | ||
import hudson.model.BooleanParameterValue; | ||
import hudson.model.Descriptor; | ||
import hudson.model.ParameterValue; | ||
import hudson.model.ParametersAction; | ||
import hudson.model.TaskListener; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* | ||
* @author Chris Johnson | ||
*/ | ||
public class BooleanParameters extends AbstractBuildParameters { | ||
|
||
private List<BooleanParameterConfig> configs; | ||
|
||
@DataBoundConstructor | ||
public BooleanParameters(List <BooleanParameterConfig> configs ){ | ||
this.configs = configs; | ||
} | ||
|
||
@Override | ||
public Action getAction(AbstractBuild<?, ?> build, TaskListener listener) throws IOException, InterruptedException, DontTriggerException { | ||
|
||
List<ParameterValue> values = new ArrayList<ParameterValue>(); | ||
for (BooleanParameterConfig config : configs) { | ||
values.add(new BooleanParameterValue(config.getName(), config.getValue())); | ||
} | ||
return new ParametersAction(values); | ||
} | ||
|
||
public List<BooleanParameterConfig> getConfigs() { | ||
return configs; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<AbstractBuildParameters> { | ||
@Override | ||
public String getDisplayName() { | ||
return "Boolean parameters"; | ||
} | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/resources/hudson/plugins/parameterizedtrigger/BooleanParameterConfig/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:entry field="name" title="${%Name}"> | ||
<f:textbox /> | ||
</f:entry> | ||
<f:entry field="value"> | ||
<f:booleanRadio true="${%True}" false="${%False}"/> | ||
</f:entry> | ||
</j:jelly> |
16 changes: 16 additions & 0 deletions
16
src/main/resources/hudson/plugins/parameterizedtrigger/BooleanParameters/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:entry title="" field="configs"> | ||
<f:repeatable field="configs" noAddButton="true" minimum="1"> | ||
<j:set var="instance" value="${instance.descriptor!=descriptor?null:instance}"/><!-- work around until 1.382 --> | ||
<table width="100%"> | ||
<st:include class="${descriptor.clazz}" page="config.jelly" /> | ||
<f:entry> | ||
<div align="right"> | ||
<input type="button" value="${%Add parameter...}" class="repeatable-add show-if-last" /> | ||
<input type="button" value="${%Delete}" class="repeatable-delete show-if-not-only" style="margin-left: 1em;" /> | ||
</div> | ||
</f:entry> | ||
</table> | ||
</f:repeatable> | ||
</f:entry> | ||
</j:jelly> |
3 changes: 3 additions & 0 deletions
3
src/main/resources/hudson/plugins/parameterizedtrigger/BooleanParameters/help-configs.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
This passes Boolean parameters to the downstream jobs | ||
</div> |