Skip to content

Commit

Permalink
[FIXED JENKINS-51171] - Use Regex to filter for an Buildparameter
Browse files Browse the repository at this point in the history
[FIXED JENKINS-43605] - ability to specify parameters to show and
parameters to exclude for a view
  • Loading branch information
fredg02 committed Sep 1, 2019
1 parent d274774 commit a054e2b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@

public class BuildParametersColumn extends ListViewColumn {

private boolean singlePara;
private String parameterName;
private boolean useRegex;
private String regex;

@DataBoundConstructor
public BuildParametersColumn(boolean singlePara, String parameterName) {
public BuildParametersColumn(boolean useRegex, String regex) {
super();
this.singlePara = singlePara;
this.parameterName = parameterName;
this.useRegex = useRegex;
this.regex = regex;
}

public BuildParametersColumn() {
this(false, "");
}

public boolean isSinglePara(){
return singlePara;
public boolean isUseRegex(){
return useRegex;
}

public String getParameterName(){
return parameterName;
public String getRegex(){
return regex;
}

public String getBuildParameters(Job<?, ?> job) {
Expand All @@ -69,7 +69,7 @@ public String getBuildParameters(Job<?, ?> job) {
if(action instanceof ParametersAction) {
ParametersAction pa = (ParametersAction)action;
for (ParameterValue p : pa.getParameters()) {
if(!isSinglePara() || p.getName().equalsIgnoreCase(parameterName)){
if(!isUseRegex() || p.getName().matches(regex)){
s.append(p.getShortDescription()).append("<br/>");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<p>${%This column shows a single build parameter or all build parameters of the current/last build.}</p>
<f:optionalBlock field="singlePara" title="${%Show single parameter}" inline="true">
<f:entry title="${%Parameter name}">
<f:textbox field="parameterName" default="" />
<p>${%This column shows either all build parameters or build parameters matching a regular expression of the current/last build.}</p>
<f:optionalBlock field="useRegex" title="${%Use regular expression}" inline="true">
<f:entry field="regex" title="${%Regular expression}" default="">
<f:textbox />
</f:entry>
</f:optionalBlock>
</f:block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

This\ column\ shows\ a\ single\ build\ parameter\ or\ all\ build\ parameters\ of\ the\ current/last\ build.=Diese Spalte zeigt einen einzigen Buildparameter oder alle Buildparameter des aktuellen/letzten Builds an.
Show\ single\ parameter=Zeige nur einen Buildparameter an
Parameter\ name=Parametername
This\ column\ shows\ either\ all\ build parameters\ or\ build\ parameters\ matching\ a\ regular\ expression\ of\ the\ current/last\ build.=Diese Spalte zeigt entweder alle Buildparameter oder Buildparameter, die zu einem regulären Ausdruck passen, des aktuellen/letzten Builds an.
Use\ regular\ expression=Benutze regulären Ausdruck
Regular\ expression=Regulärer Ausdruck
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div>
Here are a few examples for regular expressions:
<table style="margin-left: 10px;">
<tr>
<td style="padding: 2px"><b>.*</b></td><td style="padding: 2px">matches any character sequence</td>
</tr>
<tr>
<td style="padding: 2px"><b>foo.*</b></td><td style="padding: 2px">matches any string that starts with "foo"</td>
</tr>
<tr>
<td style="padding: 2px"><b>^((?!bar).)*$</b></td><td style="padding: 2px">matches any string that does not start with "bar"</td>
</tr>
<tr>
<td style="padding: 2px"><b>(?i)</b></td><td style="padding: 2px">makes the regular expression case insensitive</td>
</tr>
</table>
<p>
You can find more info here:<br/>
<ul>
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html</a></li>
<li><a href="https://docs.oracle.com/javase/tutorial/essential/regex/">https://docs.oracle.com/javase/tutorial/essential/regex/</a></li>
</ul>
</div>

0 comments on commit a054e2b

Please sign in to comment.