[英]Running non-matrix stages in parallel to a matrix in Jenkins declarative-pipeline
[英]How to run stages with and without matrix in parallel in Jenkins declarative-pipeline?
我正在嘗試並行運行非矩陣階段和矩陣階段。 我希望階段('Build - Win Mac')和階段('Build - Linux')並行運行。 根據https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix “如果階段指令嵌套在並行或矩陣指令中,則不可能在階段指令中嵌套並行或矩陣塊矩陣塊本身”。 所以我正在尋找解決這種情況的方法。 請在下面找到我的示例階段並建議我如何實現這一目標
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
}
}
}
我不能用純聲明式管道來實現,但如果你混合聲明式+腳本化,它是可能的
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.