parameter filter can only filter by StringParameterValue, BooleanParameterValue and FileParameterValue. So we can't filter by custom parameters.

      I can't understand why can't we change ParameterFilter class getStringValue function to something like this:

      protected String getStringValue(ParameterValue value) {
      		if (value instanceof StringParameterValue) {
      			return ((StringParameterValue) value).value;
      		} else if (value instanceof BooleanParameterValue) {
      			boolean bval = ((BooleanParameterValue) value).value;
      			return String.valueOf(bval);
      		} else if (value instanceof FileParameterValue) {
      			// not the full path - just the name
      			// this is the only public value available to us
      			String file = ((FileParameterValue) value).getOriginalFileName();
      			return file;
      		} else {
      			return value.toString();
      		}
      	}
      

      mine difference is return value.toString(); not return null;

          [JENKINS-18386] more flexible job filter by parameter

          This would be easy to implement, but I don't know of any parameters that use "toString". If you just mean your own company's custom parameters, then it can still be implemented, it just won't really be easy to test before releasing. It would be more helpful if you could give an example parameter plugin that I could install and test against. I tried a couple, but they don't use "toString", so it didn't work.

          Jacob Robertson added a comment - This would be easy to implement, but I don't know of any parameters that use "toString". If you just mean your own company's custom parameters, then it can still be implemented, it just won't really be easy to test before releasing. It would be more helpful if you could give an example parameter plugin that I could install and test against. I tried a couple, but they don't use "toString", so it didn't work.

          Maris Zulis added a comment -

          I'm trying to use this plugin: https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin

          I set Node parameter with name "slave". And my job only executes shell command "echo $slave". If I can print this parameter then there should be a way to make it string.

          I also installed https://wiki.jenkins-ci.org/display/JENKINS/Show+Build+Parameters+Plugin and it also show this parameter

          As I can see in code https://github.com/petehayes/show-build-parameters-plugin/blob/master/src/main/java/jenkins/plugins/show_build_parameters/ShowParametersBuildAction.java

          script only collects ParameterValue List with getParameters function and then prints it out
          https://github.com/petehayes/show-build-parameters-plugin/blob/master/src/main/resources/jenkins/plugins/show_build_parameters/ShowParametersBuildAction/summary.jelly

          Maybe I don't understand correctly but it should use toString() to convert it

          Maris Zulis added a comment - I'm trying to use this plugin: https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin I set Node parameter with name "slave". And my job only executes shell command "echo $slave". If I can print this parameter then there should be a way to make it string. I also installed https://wiki.jenkins-ci.org/display/JENKINS/Show+Build+Parameters+Plugin and it also show this parameter As I can see in code https://github.com/petehayes/show-build-parameters-plugin/blob/master/src/main/java/jenkins/plugins/show_build_parameters/ShowParametersBuildAction.java script only collects ParameterValue List with getParameters function and then prints it out https://github.com/petehayes/show-build-parameters-plugin/blob/master/src/main/resources/jenkins/plugins/show_build_parameters/ShowParametersBuildAction/summary.jelly Maybe I don't understand correctly but it should use toString() to convert it

          Code changed in jenkins
          User: jacob_robertson
          Path:
          src/main/java/hudson/views/MostRecentJobsFilter.java
          src/main/java/hudson/views/ParameterFilter.java
          src/main/java/hudson/views/RegExJobFilter.java
          src/main/resources/hudson/views/MostRecentJobsFilter/config.jelly
          src/main/resources/hudson/views/ParameterFilter/config.jelly
          src/main/resources/hudson/views/RegExJobFilter/config.jelly
          src/test/java/hudson/views/ParameterFilterTest.java
          http://jenkins-ci.org/commit/view-job-filters-plugin/b10005a320585ed2fa03d6b06064fdb53fa0019c
          Log:
          fixed JENKINS-18386, JENKINS-17597, JENKINS-17093, JENKINS-18399

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: jacob_robertson Path: src/main/java/hudson/views/MostRecentJobsFilter.java src/main/java/hudson/views/ParameterFilter.java src/main/java/hudson/views/RegExJobFilter.java src/main/resources/hudson/views/MostRecentJobsFilter/config.jelly src/main/resources/hudson/views/ParameterFilter/config.jelly src/main/resources/hudson/views/RegExJobFilter/config.jelly src/test/java/hudson/views/ParameterFilterTest.java http://jenkins-ci.org/commit/view-job-filters-plugin/b10005a320585ed2fa03d6b06064fdb53fa0019c Log: fixed JENKINS-18386 , JENKINS-17597 , JENKINS-17093 , JENKINS-18399

          Code changed in jenkins
          User: jacob_robertson
          Path:
          src/main/webapp/most-recent-help.html
          src/main/webapp/regex-help.html
          http://jenkins-ci.org/commit/view-job-filters-plugin/26f950ad6f7a5b599d0f1e859743e3aae92f2530
          Log:
          fixed JENKINS-18386, JENKINS-17597, JENKINS-17093, JENKINS-18399

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: jacob_robertson Path: src/main/webapp/most-recent-help.html src/main/webapp/regex-help.html http://jenkins-ci.org/commit/view-job-filters-plugin/26f950ad6f7a5b599d0f1e859743e3aae92f2530 Log: fixed JENKINS-18386 , JENKINS-17597 , JENKINS-17093 , JENKINS-18399

          Jacob Robertson added a comment - - edited

          I implemented this, but it's pretty sketchy. Essentially, it will do a toString, and whatever comes back will be matched on. In the examples you gave, they don't actually have a very good toString method, however, it will actually work if you use a flexible enough regex. For example, if the toString returns something like "SomeParam(name=foo, value=bar)", and you want to match on the value "bar", you would have to write a regex that took into account the actual toString, like doing ".*bar.*" or whatever. This will work for the case you described. I forgot the exact toString, but it's something like the example I gave here.

          Jacob Robertson added a comment - - edited I implemented this, but it's pretty sketchy. Essentially, it will do a toString, and whatever comes back will be matched on. In the examples you gave, they don't actually have a very good toString method, however, it will actually work if you use a flexible enough regex. For example, if the toString returns something like "SomeParam(name=foo, value=bar)", and you want to match on the value "bar", you would have to write a regex that took into account the actual toString, like doing ".*bar.*" or whatever. This will work for the case you described. I forgot the exact toString, but it's something like the example I gave here.

            jacob_robertson Jacob Robertson
            mzulis Maris Zulis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: