[英]How to run stages with and without matrix in parallel in Jenkins declarative-pipeline?
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.我希望阶段('Build - Win Mac')和阶段('Build - Linux')并行运行。 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".根据https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix “如果阶段指令嵌套在并行或矩阵指令中,则不可能在阶段指令中嵌套并行或矩阵块矩阵块本身”。 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"
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.