Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30182

view-job-filters plugin, parameterized jobs filter, does not work. exceptions thrown from build filter (wrapper) column

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 1.609.2 LTS with view-job-filters plugin 1.27 (plugin includes build filter (wrapper) column). Other plugins are up-to-date w.r.t. LTS versions.
      Oracle Java 7u75
    • 2.2

      Jenkins 1.609.2 LTS with view-job-filters plugin 1.27 (plugin includes build filter (wrapper) column). Other plugins are up-to-date w.r.t. LTS versions. Oracle Java 7u75.

      See also JENKINS-21862

      1. Add a new list view (in "My Views")
      Select "filter build queue" and "filter build executors"
      "job filters" - All selected jobs. Do not select projects by checkbox.
      Do select "Use regex to include jobs into the view" and enter regex.
      Add new column "build parameters", showing value of parameter GERRIT_BRANCH.

      Result:
      (a) The view includes the expected list of projects selected by job name, with GERRIT_BRANCH column showing different values depending on the last completed build of each project. Good.

      2. Edit view and add a new "parameterized jobs filter" - parameter name is "GERRIT_BRANCH", matching value is "RB12.34", all options un-checked, match type is "exclude unmatched"

      Result:
      (a) The view's project list includes fewer projects, only those where GERRIT_BRANCH matched RB12.34 in the last completed build. Good.

      (b) The Build History only includes builds where GERRIT_BRANCH matched. Good.

      3. Edit view, go to parameterized jobs filter, select "match against this many previous builds", blank or zero for all

      Result:
      (a) The view's project list includes more projects, with GERRIT_BRANCH column showing different values depending on the last completed build of each project. Good.

      (b) The Build History now includes builds that should have been filtered by the parameterized jobs filter. Bad.

      4. Edit view and add a new build filter (wrapper) column, select "build parameters", show the single parameter GERRIT_BRANCH. This is the same as the column we added before, except this is inside the build filter wrapper.

      Result:
      (a) the new filtered build parameters column is empty, when it should show the same GERRIT_BRANCH as the unfiltered Build Parameters column. Bad.

      (b) The jenkins server log shows exceptions like below, one for each project in the View's project list:
      Aug 25, 2015 9:35:10 AM WARNING hudson.ExpressionFactory2$JexlExpression evaluate
      Caught exception evaluating: it.getBuildParameters(job) in /user/haha/my-views/view/hoho/. Reason: java.lang.IllegalStateException: /local/opt/jenkins/8060/jenkins_home/jobs/full-SC-w2012-vc12-x86/builds/833 already existed; will not overwite with full-SC-w2012-vc12-x86 #833
      java.lang.IllegalStateException: /local/opt/jenkins/8060/jenkins_home/jobs/full-SC-w2012-vc12-x86/builds/833 already existed; will not overwite with full-SC-w2012-vc12-x86 #833
      at hudson.model.RunMap.put(RunMap.java:187)
      at hudson.views.BuildFilterColumn$JobWrapper._getRuns(BuildFilterColumn.java:125)
      at hudson.model.Job.getLastBuild(Job.java:858)
      at jenkins.plugins.extracolumns.BuildParametersColumn.getBuildParameters(BuildParametersColumn.java:63)
      ... much more traceback

          [JENKINS-30182] view-job-filters plugin, parameterized jobs filter, does not work. exceptions thrown from build filter (wrapper) column

          Ben Keller added a comment -

          Jenkins 1.636; view-job-filters plugin 1.27

          Using a Parameterized Jobs Filter with the Value either blank or set, in combination with a "Build Filter (Wrapper) Column" gives me an "N/A" in the wrapped column (in my case, "Last Success") and a stack trace in the log. Note that outside of the wrapped column, the Parameterized Jobs Filter is working correctly, i.e. creating views with the correct jobs, both when the Value is blank and when the Value is set.

          The stack traces I'm seeing are very similar to those in https://issues.jenkins-ci.org/browse/JENKINS-21862 also.

          The two types of stack traces in the log are:

          Nov 09, 2015 6:01:39 PM WARNING hudson.ExpressionFactory2$JexlExpression evaluate
          Caught exception evaluating: job.lastSuccessfulBuild in /view/test_view_job_filters/. Reason: java.lang.reflect.InvocationTargetException
          java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          [...snip...]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)
          Caused by: java.lang.ClassCastException: hudson.views.BuildFilterColumn$JobWrapper cannot be cast to hudson.model.TopLevelItem
          at jenkins.model.Jenkins.getRootDirFor(Jenkins.java:306)
          at hudson.model.AbstractItem.getRootDir(AbstractItem.java:172)
          at jenkins.model.Jenkins.expandVariablesForDirectory(Jenkins.java:2061)
          at jenkins.model.Jenkins.getBuildDirFor(Jenkins.java:2057)
          at hudson.model.Job.getBuildDir(Job.java:833)
          at jenkins.model.PeepholePermalink.getPermalinkFile(PeepholePermalink.java:78)
          at jenkins.model.PeepholePermalink.resolve(PeepholePermalink.java:86)
          at hudson.model.Job.getLastSuccessfulBuild(Job.java:891)
          ... 151 more

          and

          Nov 10, 2015 12:57:43 PM WARNING hudson.ExpressionFactory2$JexlExpression evaluate
          Caught exception evaluating: job.lastSuccessfulBuild in /view/view-job-filters-test/. Reason: java.lang.reflect.InvocationTargetException
          java.lang.reflect.InvocationTargetException
          at sun.reflect.GeneratedMethodAccessor703.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125)
          [...snip...]
          at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
          at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)
          Caused by: java.lang.ClassCastException

          Ben Keller added a comment - Jenkins 1.636; view-job-filters plugin 1.27 Using a Parameterized Jobs Filter with the Value either blank or set, in combination with a "Build Filter (Wrapper) Column" gives me an "N/A" in the wrapped column (in my case, "Last Success") and a stack trace in the log. Note that outside of the wrapped column, the Parameterized Jobs Filter is working correctly, i.e. creating views with the correct jobs, both when the Value is blank and when the Value is set. The stack traces I'm seeing are very similar to those in https://issues.jenkins-ci.org/browse/JENKINS-21862 also. The two types of stack traces in the log are: Nov 09, 2015 6:01:39 PM WARNING hudson.ExpressionFactory2$JexlExpression evaluate Caught exception evaluating: job.lastSuccessfulBuild in /view/test_view_job_filters/. Reason: java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) [...snip...] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException: hudson.views.BuildFilterColumn$JobWrapper cannot be cast to hudson.model.TopLevelItem at jenkins.model.Jenkins.getRootDirFor(Jenkins.java:306) at hudson.model.AbstractItem.getRootDir(AbstractItem.java:172) at jenkins.model.Jenkins.expandVariablesForDirectory(Jenkins.java:2061) at jenkins.model.Jenkins.getBuildDirFor(Jenkins.java:2057) at hudson.model.Job.getBuildDir(Job.java:833) at jenkins.model.PeepholePermalink.getPermalinkFile(PeepholePermalink.java:78) at jenkins.model.PeepholePermalink.resolve(PeepholePermalink.java:86) at hudson.model.Job.getLastSuccessfulBuild(Job.java:891) ... 151 more and Nov 10, 2015 12:57:43 PM WARNING hudson.ExpressionFactory2$JexlExpression evaluate Caught exception evaluating: job.lastSuccessfulBuild in /view/view-job-filters-test/. Reason: java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor703.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125) [...snip...] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException

          Carl Jokl added a comment -

          Having examined the source code to try and fix it myself, I have observed the following explanation for the behaviour.

          This can be used to filter Jobs where parameters are typically used on an individual run. When filtering at the Job level the behaviour based on the source code logic is:
          If "match against many previous builds" is set then the Job will match if any of those builds/runs had the specified parameter set.
          If "match against many previous builds" is not set the Job will match only if the latest build/run had the specified parameter set.

          The filter has the logic available to filter builds/runs that match the parameter. This would only work if the code using the filter is making use of the build/run filter logic. This seems to imply that the filter itself is working correctly when filtering at the Job level. This behaviour may not be intuitive without knowing why it behaves the way it does. As far as I understand, the problem is with code using the filter not filtering out just the runs with a given parameter set. As I am new to the Jenkins / plugin source code it would help to check my observations are reasonable.

          Carl Jokl added a comment - Having examined the source code to try and fix it myself, I have observed the following explanation for the behaviour. This can be used to filter Jobs where parameters are typically used on an individual run. When filtering at the Job level the behaviour based on the source code logic is: If "match against many previous builds" is set then the Job will match if any of those builds/runs had the specified parameter set. If "match against many previous builds" is not set the Job will match only if the latest build/run had the specified parameter set. The filter has the logic available to filter builds/runs that match the parameter. This would only work if the code using the filter is making use of the build/run filter logic. This seems to imply that the filter itself is working correctly when filtering at the Job level. This behaviour may not be intuitive without knowing why it behaves the way it does. As far as I understand, the problem is with code using the filter not filtering out just the runs with a given parameter set. As I am new to the Jenkins / plugin source code it would help to check my observations are reasonable.

          Jesse Glick added a comment -

          Not sure about the rest, but the {{java.lang.ClassCastException: hudson.views.BuildFilterColumn$JobWrapper cannot be cast to hudson.model.TopLevelItem
          at jenkins.model.Jenkins.getRootDirFor(Jenkins.java:306)}} should have been fixed by PR 17 (was causing a test failures when updating the Jenkins baseline).

          Jesse Glick added a comment - Not sure about the rest, but the {{java.lang.ClassCastException: hudson.views.BuildFilterColumn$JobWrapper cannot be cast to hudson.model.TopLevelItem at jenkins.model.Jenkins.getRootDirFor(Jenkins.java:306)}} should have been fixed by PR 17 (was causing a test failures when updating the Jenkins baseline).

            jglick Jesse Glick
            hushp1pt Tony Wallace
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: