I am trying to run non-matrix stage with matrix stage in parallel. I want stage ('Build - Win Mac') & stage ('Build - Linux') to run parallel. As per https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix "It is not possible to nest a parallel or matrix block within a stage directive if that stage directive is nested within a parallel or matrix block itself". So I am looking for a workaround for this situation. Please find below my sample stages and suggest how i can achieve this
stages {
stage ('Build') {
stage ('Build - Win Mac') {
// non-docker build for Win & Mac using Matrix
matrix {
axes {
axis {
name 'PLATFORM'
values 'Win', 'Mac'
}
axis {
name 'ADDRESS_SANITIZER'
values 'disabled', 'enabled'
}
}
stage ('build'){
steps {
// build step for win, mac
}
}
}
stage ('Build - Linux'){
// docker build for Linux
}
}
}
I can't make it with a pure declarative pipeline but If you mix declarative + scripted it can be possible
pipeline {
agent any;
stages {
stage('parallel') {
parallel {
stage('metrix-build') {
steps {
echo "Metric-Build"
// will take care Metrix kind of scenario with scripted way [start]
script {
def axisNode = ["osx-agent-1","osx-agent-2"]
def axisTool = ["jdk7","jdk8"]
def tasks = [:]
for(int i=0; i< axisNode.size(); i++) {
def axisNodeValue = axisNode[i]
for(int j=0; j< axisTool.size(); j++) {
def axisToolValue = axisTool[j]
tasks["${axisNodeValue}/${axisToolValue}"] = {
node(axisNodeValue) {
def javaHome = tool axisToolValue
println "Node=${env.NODE_NAME}"
println "Java=${javaHome}"
}
}
}
}
parallel tasks
}
//[End here]
}
}
stage('non-metric-build') {
steps {
echo "non metrics build"
}
}
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.