• Declarative backlog

        [JENKINS-40986] Matrix structure for Declarative Pipeline

        Denis Dudarev added a comment -

        Thank you for great feature!

        I could only see 2 axis cases in tests and json files. Is this a limit for there?

        Anyway I need better instructions to check it out. For example - sample Jenkinsfile with 3axis build would be very useful.

        Denis Dudarev added a comment - Thank you for great feature! I could only see 2 axis cases in tests and json files. Is this a limit for there? Anyway I need better instructions to check it out. For example - sample Jenkinsfile with 3axis build would be very useful.

        Denis Dudarev added a comment -

        Hm. I've reviewed json file more detailed. It seems to be quite agile implementation, covering most of cases above. So what I need (and most users I believe) is a Jenkinsfile example, to review end-user syntax.

        Denis Dudarev added a comment - Hm. I've reviewed json file more detailed. It seems to be quite agile implementation, covering most of cases above. So what I need (and most users I believe) is a Jenkinsfile example, to review end-user syntax.

        Andrew Bayer added a comment -

        Andrew Bayer added a comment - https://github.com/jenkinsci/pipeline-model-definition-plugin/tree/master/pipeline-model-definition/src/test/resources/matrix has a whole bunch of Jenkinsfile examples/test cases. =)

        Denis Dudarev added a comment -

        Got it, thanks!

        Denis Dudarev added a comment - Got it, thanks!

        Denis Dudarev added a comment -

        Results of my humble review:

        • It seems to be usable, it covers user cases
        • Excludes syntax is quite huge, but I have no fast good idea for much compact one without imperative expressions from original matrix functionality, it could be very annoying to avoid all uninterested combinations with axis count >2, especially in cases where *most* of combinations are uninterested (e.g. at the start of a project)

        Denis Dudarev added a comment - Results of my humble review: It seems to be usable, it covers user cases Excludes syntax is quite huge, but I have no fast good idea for much compact one without imperative expressions from original matrix functionality, it could be very annoying to avoid all uninterested combinations with axis count >2, especially in cases where * most * of combinations are uninterested (e.g. at the start of a project)

        +1 on the exclude syntax, it's taking a lot of space.
        Also, can the values field of the axis block be dynamic instead of using a filter parameter?
        I have a use case with axes with a lot of values depending on a parameter, so if I can't act on the matrix values, my only option is to handle it in a when block?
        Also, in most cases, I would rather use a global variable to store my axes values as well, makes it easier to maintain and I could re-use it in another matrix block further down in the script.
        But overall I'm very happy to see a matrix block in declarative pipeline.

        Simon Larouche-Gagne added a comment - +1 on the exclude syntax, it's taking a lot of space. Also, can the values field of the axis block be dynamic instead of using a filter parameter? I have a use case with axes with a lot of values depending on a parameter, so if I can't act on the matrix values, my only option is to handle it in a when block? Also, in most cases, I would rather use a global variable to store my axes values as well, makes it easier to maintain and I could re-use it in another matrix block further down in the script. But overall I'm very happy to see a matrix block in declarative pipeline.

        Joan Touzet added a comment -

        One enhancement that might be nice, if possible, is to have the values for an axis name be supported as non-literals. I don't seem to be able to make this work in the current version. Sorry if this isn't the right place, but you were asking for examples above...

         

        Example:

        pipeline {
          environment {
             LOW_ERLANG_VER = '19.3.6.8'
             MID_ERLANG_VER = '20.3.8.24'
             HIGH_ERLANG_VER = '22.2'
        {{  }}}

          stages {
            // ...
            // Other stages that need the values above
            // ...
            stage("Build") {
              matrix {
                axes {
                  axis {
                    name 'ERLANG_VERSION'
                    values "{$env.LOW_ERLANG_VER}", "${env.MID_ERLANG_VER}", "${env.HIGH_ERLANG_VER}"
        {{          }}}
                } // axes
                // ...
                // do the build with ${ERLANG_VERSION}
                // ...
              } // matrix
            } // stage
          } // stages
        } // pipeline

        if that makes sense.

        Joan Touzet added a comment - One enhancement that might be nice, if possible, is to have the values for an axis name be supported as non-literals. I don't seem to be able to make this work in the current version. Sorry if this isn't the right place, but you were asking for examples above...   Example: pipeline {   environment {      LOW_ERLANG_VER = '19.3.6.8'      MID_ERLANG_VER = '20.3.8.24'      HIGH_ERLANG_VER = '22.2' {{  }}}   stages {     // ...     // Other stages that need the values above     // ...     stage("Build") {       matrix {         axes {           axis {             name 'ERLANG_VERSION'             values "{$env.LOW_ERLANG_VER}", "${env.MID_ERLANG_VER}", "${env.HIGH_ERLANG_VER}" {{          }}}         } // axes         // ...         // do the build with ${ERLANG_VERSION }         // ...       } // matrix     } // stage   } // stages } // pipeline if that makes sense.

        Liam Newman added a comment -

        wohali
        This totally makes sense. An issue has been opened for it. https://issues.jenkins-ci.org/browse/JENKINS-61047

        Liam Newman added a comment - wohali This totally makes sense. An issue has been opened for it. https://issues.jenkins-ci.org/browse/JENKINS-61047

        Matrix stages in declarative pipelines have already been implemented and documented: https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix

        Can this issue be closed now, or is something still missing?

        Kalle Niemitalo added a comment - Matrix stages in declarative pipelines have already been implemented and documented: https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix Can this issue be closed now, or is something still missing?

        It seems the last matrix-specific change without a separate Jira issue was in pipeline-model-definition-1.6.0:

        • Add support for matrix to the directive generator (#380)

        So, I'd consider this issue resolved in that version. Please reopen if you disagree.

        Kalle Niemitalo added a comment - It seems the last matrix-specific change without a separate Jira issue was in pipeline-model-definition-1.6.0 : Add support for matrix to the directive generator ( #380 ) So, I'd consider this issue resolved in that version. Please reopen if you disagree.

          bitwiseman Liam Newman
          arthurlutz Arthur Lutz
          Votes:
          32 Vote for this issue
          Watchers:
          43 Start watching this issue

            Created:
            Updated:
            Resolved: