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

The "Restrict matrix execution to subset" Groovy filter is not evaluate

      The "groovy filter" value of the "Restrict matrix execution to subset" is never evaluated. So we cannot use this feature to trigger different jobs depending on a variable value by setting the filter to "${VAR}".contains("alu").

      I'm preparing a pull-request for this. I will update the issue then.

          [JENKINS-17176] The "Restrict matrix execution to subset" Groovy filter is not evaluate

          Adrien Lecharpentier added a comment - Here is my pull request [1] and the BuildHive result [2] . [1] : https://github.com/jenkinsci/parameterized-trigger-plugin/pull/37 [2] : https://buildhive.cloudbees.com/job/jenkinsci/job/parameterized-trigger-plugin/47/

          cjo9900 added a comment -

          Comments from the pull request

          This should not be evaluated here as the MatrixSubsetAction filter should be referring to the triggered matrix project, so in most cases this will return false as the AXIS that the matrix project has will not be available which are the normal cases for checking.
          So it can only reliably be checked in the Matrix project build.

          Actual evaluation takes place in the Matrix build in
          https://github.com/jenkinsci/parameterized-trigger-plugin/blob/master/src/main/java/hudson/plugins/parameterizedtrigger/matrix/MatrixBuildListenerImpl.java

          Thanks but for the evaluation, this Class is not called during the process.

          Should be called from DefaultMatrixExecutionStrategyImpl.java in a Matrix project from the static function in the hudson.matrix.listeners.MatrixBuildListener class.

          https://github.com/jenkinsci/jenkins/blob/6d95e3680c8edf49c2353633dd9c1a7072440989/core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java#L123

          Sure but in my case, I have a freestyle project with a parameterized trigger configurations in post-build action to determine which build to launch next. I have to evaluate the Groovy filter which is never done in that case.

          cjo9900 added a comment - Comments from the pull request This should not be evaluated here as the MatrixSubsetAction filter should be referring to the triggered matrix project, so in most cases this will return false as the AXIS that the matrix project has will not be available which are the normal cases for checking. So it can only reliably be checked in the Matrix project build. Actual evaluation takes place in the Matrix build in https://github.com/jenkinsci/parameterized-trigger-plugin/blob/master/src/main/java/hudson/plugins/parameterizedtrigger/matrix/MatrixBuildListenerImpl.java Thanks but for the evaluation, this Class is not called during the process. Should be called from DefaultMatrixExecutionStrategyImpl.java in a Matrix project from the static function in the hudson.matrix.listeners.MatrixBuildListener class. https://github.com/jenkinsci/jenkins/blob/6d95e3680c8edf49c2353633dd9c1a7072440989/core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java#L123 Sure but in my case, I have a freestyle project with a parameterized trigger configurations in post-build action to determine which build to launch next. I have to evaluate the Groovy filter which is never done in that case.

          cjo9900 added a comment -

          From your use case it seems that you want to run the filter against the current build variables to allow/prevent the downstream build to trigger.

          If this is the case you should look at the run condition branch and create a groovy run condition.

          https://github.com/jenkinsci/parameterized-trigger-plugin/pull/17

          cjo9900 added a comment - From your use case it seems that you want to run the filter against the current build variables to allow/prevent the downstream build to trigger. If this is the case you should look at the run condition branch and create a groovy run condition. https://github.com/jenkinsci/parameterized-trigger-plugin/pull/17

          ikedam added a comment -

          As commented https://github.com/jenkinsci/parameterized-trigger-plugin/pull/37, it seems work in Jenkins 1.509.2.
          If the problem remains, reopen this issue and please let me know the steps to reproduce.

          ikedam added a comment - As commented https://github.com/jenkinsci/parameterized-trigger-plugin/pull/37 , it seems work in Jenkins 1.509.2. If the problem remains, reopen this issue and please let me know the steps to reproduce.

          Dan Albu added a comment -

          I am having the same issue manifest if there is a combination filter already set up on the matrix job.

          Dan Albu added a comment - I am having the same issue manifest if there is a combination filter already set up on the matrix job.

          ikedam added a comment -

          Could not reproduce with Jenkins 1.596.2, parameterized-trigger 2.26.
          Reopen the issue with detailed instructions to reproduce the problem.

          Steps I tested:

          • Create a multi-configuration project "downstream"
            • Add axes
              • User-defined Axis
                • Name: axis1
                • Values: value1 value2
              • User-defined Axis
                • Name: axis2
                • Values: value1 value2
            • Set "Combination Filter"
              • axis1 != axis2
          • Run "downstream"
            • "axis1=value1,axis2=value2" and "axis1=value2, axis2=value1" will be run.
          • Create a freestyle project "upstream"
            • Add "Trigger parameterized build on other projects" in "Post-build Actions"
              • Projects to build: downstream
              • Add "Restrict matrix execution to a subset"
                • Groovy filter: axis1 == 'value1'
          • Run "upstream"

          Result:

          • "axis1=value1,axis2=value2" will be run on "downstream"

          ikedam added a comment - Could not reproduce with Jenkins 1.596.2, parameterized-trigger 2.26. Reopen the issue with detailed instructions to reproduce the problem. Steps I tested: Create a multi-configuration project "downstream" Add axes User-defined Axis Name: axis1 Values: value1 value2 User-defined Axis Name: axis2 Values: value1 value2 Set "Combination Filter" axis1 != axis2 Run "downstream" "axis1=value1,axis2=value2" and "axis1=value2, axis2=value1" will be run. Create a freestyle project "upstream" Add "Trigger parameterized build on other projects" in "Post-build Actions" Projects to build: downstream Add "Restrict matrix execution to a subset" Groovy filter: axis1 == 'value1' Run "upstream" Result: "axis1=value1,axis2=value2" will be run on "downstream"

          Dan Albu added a comment -

          ikedam try with a maven project as upstream and a matrix configuration. Also try to use the following combo in the matrix combination filter:
          !((s == 'acdca' && f == 'wsmana' && a=='a')||(s == 'acdca' && f == 'wsmana' && a=='b')) and on the upstream project try to run any other combo.

          If you still can't reproduce i will attach my jobs and plugin versions of everything

          Dan Albu added a comment - ikedam try with a maven project as upstream and a matrix configuration. Also try to use the following combo in the matrix combination filter: !((s == 'acdca' && f == 'wsmana' && a=='a')||(s == 'acdca' && f == 'wsmana' && a=='b')) and on the upstream project try to run any other combo. If you still can't reproduce i will attach my jobs and plugin versions of everything

            huybrechts huybrechts
            alecharp Adrien Lecharpentier
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: