Hello all!
I'm pleased to announce the release of Declarative Pipeline 1.4.0-beta-1 with Matrix Stages. This feature allows pipeline authors to specify a matrix of one or more dimensions and run a set of stages on the combination of values specified. One simple use case where Matrix Stages are valuable is running browser tests on several operating systems and browser combinations. Let’s say we want to run tests on Linux, OS X, and Windows for browsers Chrome, Firefox, IE, and Safari. We’ll want to run tests for IE on Windows only and we’ll want tests for Safari to run on OS X and Windows. Here’s what that scenario will look like using the new “matrix” directive: Jenkinsfile ---------- pipeline { agent none stages { stage("foo") { matrix { axes { axis { name 'os' values "linux", "windows", "mac" } axis { name 'browser' values "firefox", "chrome", "safari", "ie" } } excludes { exclude { axis { name 'os' values 'linux' } axis { name 'browser' values 'safari' } } exclude { axis { name 'os' notValues 'windows' } axis { name 'browser' values 'ie' } } } stages { stage("first") { steps { echo "Running on OS=$os, BROWSER=$browser" } } stage("second") { steps { // ... Second stage steps ... } } } } } } } ---------- In the example, we specify two axes and the values for each of them. Then, we use the optional “excludes” directive to remove undesired combinations from the matrix. Finally, we specify one or more stages that we want to run on each combination. Log fragment: … [Pipeline] stage [Pipeline] { (foo) [Pipeline] parallel [Pipeline] { (Branch: Matrix: os = 'linux', browser = 'firefox') [Pipeline] { (Branch: Matrix: os = 'windows', browser = 'firefox') [Pipeline] { (Branch: Matrix: os = 'mac', browser = 'firefox') [Pipeline] { (Branch: Matrix: os = 'linux', browser = 'chrome') [Pipeline] { (Branch: Matrix: os = 'windows', browser = 'chrome') [Pipeline] { (Branch: Matrix: os = 'mac', browser = 'chrome') [Pipeline] { (Branch: Matrix: os = 'windows', browser = 'safari') [Pipeline] { (Branch: Matrix: os = 'mac', browser = 'safari') [Pipeline] { (Branch: Matrix: os = 'windows', browser = 'ie') ... Declarative Pipeline 1.4.0-beta-1 is available from the experimental update center now ( https://jenkins.io/doc/developer/publishing/releasing-experimental-updates/). I look forward to hearing what you think of this feature and what you’d like to see in future updates to Declarative Pipeline. Thanks, Liam Newman Senior Software Engineer - Pipeline -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/78b8f8e6-b61c-49dc-ba24-9d25f0baa825%40googlegroups.com.