From a054e2bfde677635991aafd407e9461550e3498a Mon Sep 17 00:00:00 2001 From: Fred G Date: Sun, 1 Sep 2019 03:12:34 +0200 Subject: [PATCH] [FIXED JENKINS-51171] - Use Regex to filter for an Buildparameter [FIXED JENKINS-43605] - ability to specify parameters to show and parameters to exclude for a view --- .../extracolumns/BuildParametersColumn.java | 20 ++++++++-------- .../BuildParametersColumn/config.jelly | 8 +++---- .../config_de.properties | 6 ++--- .../BuildParametersColumn/help-regex.html | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/help-regex.html diff --git a/src/main/java/jenkins/plugins/extracolumns/BuildParametersColumn.java b/src/main/java/jenkins/plugins/extracolumns/BuildParametersColumn.java index 1e60e5d..3e73543 100644 --- a/src/main/java/jenkins/plugins/extracolumns/BuildParametersColumn.java +++ b/src/main/java/jenkins/plugins/extracolumns/BuildParametersColumn.java @@ -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) { @@ -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("
"); } } diff --git a/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config.jelly b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config.jelly index bc2cac7..6e6aa9c 100644 --- a/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config.jelly +++ b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config.jelly @@ -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"> -

${%This column shows a single build parameter or all build parameters of the current/last build.}

- - - +

${%This column shows either all build parameters or build parameters matching a regular expression of the current/last build.}

+ + +
diff --git a/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config_de.properties b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config_de.properties index 191e3e7..f5b7615 100644 --- a/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config_de.properties +++ b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/config_de.properties @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/help-regex.html b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/help-regex.html new file mode 100644 index 0000000..d3853a7 --- /dev/null +++ b/src/main/resources/jenkins/plugins/extracolumns/BuildParametersColumn/help-regex.html @@ -0,0 +1,23 @@ +
+Here are a few examples for regular expressions: + + + + + + + + + + + + + +
.*matches any character sequence
foo.*matches any string that starts with "foo"
^((?!bar).)*$matches any string that does not start with "bar"
(?i)makes the regular expression case insensitive
+

+You can find more info here:
+

+
\ No newline at end of file