Create a Matrix-like flow with Pipeline Bee Bot July 13, 2022 10:49 Updated The content of this article has moved to the new documentation site. Related articles Pipeline - Parallel execution of tasks How to Customize Checkout for Pipeline Multibranch? Pipeline - How to print out env variables available in a build Method Code Too Large Error How can I purge/clean the build queue? Comments 2 comments Sort by Date Votes Michael Fowler January 15, 2019 16:36 An example for declarative would be nice 0 Allan Burdajewicz May 03, 2019 03:08 Michael, For declarative, you would need to rely on the script { ... } block at the moment. So the solution is similar: def getTasks(axisNodes, axisTools) { def tasks = [:] for(int i=0; i< axisNodes.size(); i++) { def axisNodeValue = axisNodes[i] for(int j=0; j< axisTools.size(); j++) { def axisToolValue = axisTools[j] tasks["${axisNodeValue}/${axisToolValue}"] = { node(axisNodeValue) { def javaHome = tool axisToolValue println "Node=${env.NODE_NAME}" println "Java=${javaHome}" } } } } return tasks}pipeline { agent none stages { stage("Before") { agent any steps { echo "before" } } stage("Matrix") { steps { script { def axisNodes = ["osx-agent-1","osx-agent-2"] def axisTool = ["jdk7","jdk8"] parallel getTasks(axisNodes, axisTool) } } } stage("After") { agent any steps { echo "after" } } }} Regards, 0 Please sign in to leave a comment.
Comments
2 comments
An example for declarative would be nice
Michael,
For declarative, you would need to rely on the script { ... } block at the moment. So the solution is similar:
Regards,
Please sign in to leave a comment.