Jenkins声明式管道:矩阵构建轴的顺序执行 [英] Jenkins declarative pipeline: Sequential execution of an axis of a matrix-build

查看:71
本文介绍了Jenkins声明式管道:矩阵构建轴的顺序执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个矩阵构建,并在几个问题上运行.矩阵如下:

I am trying to set up a matrix build and am running in several issues. The matrix looks like:

stage( 'BuildAll' ) {
    matrix {
        axes {
            axis {
                name 'PLATFORM'
                values 'win32vc9', 'win32vc19' 
            }                   
            axis {
                name 'VARIANT'
                values 'debug', 'release'                   
            }
            axis {
                name 'MODULES'
                values 'repo1/module1', 'repo1/module2', 'repo2/module1', 'repo2/module2'
            }
        }

        stages {                                                
            stage( 'Checkout' ) {
            }
            stage( 'Build' ) {
            }
            stage( 'Test' ) {
            }
       }

我遇到的问题:

  • jenkins在自己的工作区中执行矩阵的每个单元,但是我的模块彼此依赖.这就是为什么我要签出它们并在相同的工作区中构建它们的原因.顺便说一句:我的构建系统可以在同一工作区中使用所有变体(调试/发行版x vc9/vc19).

  • jenkins is executing every cell of the matrix in it's own workspace but my modules depend on each other. That's why I want do check them out and build them in the same workspace. BTW: my build system is made to work with all the variants (debug/release x vc9/vc19) in the same workspace.

jenkins正在并行执行所有单元.我需要的是MODULES轴的执行序列化.

jenkins is executing all the cells in parallel. What I need, is a serialization of execution of the MODULES axis.

有什么办法可以解决这个问题吗?

Any ideas how I can work around this?

例如有没有办法描述像几个模块上的循环这样的东西,它们在一行中而不是并行地产生一系列的阶段?在这个序列中,我只能在2个轴上实现矩阵.

E.g. is there a way to descripe something like a loop over several modules that generates a sequence of stages in a row, not parallel? Within that sequence I could realize the matrix over 2 axes only.

我知道扩展的工作区插件,但是没有找到有关如何在声明式管道中使用此文档的任何文档.

I am aware of extended workspace plugin but did not find any documentation of how to use this in declarative pipelines.

非常感谢!问候,克里斯托夫

Many thanks in advance! Regards, Christoph

推荐答案

我使用 for 循环代替了 matrix axis 语法.我的解决方法不像使用 matrix 语法那样漂亮,但是可以做到它应该做的事情.

I used for loop instead of matrix and axis syntax. My workaround is not as pretty as using matrix syntax, but it does what it supposed to do.

String[] platformList = ['win32vc9', 'win32vc19']
String[] variantList = ['debug', 'release']

pipeline{
    agent any
    stages {
        stage('Deploy'){
            steps{
                script{
                    for(platform in platformList){
                        for(variant in variantList){
                            stage("Checkout"){
                                powershell label: '', script: """Write-Output Step1 "${platform}/${variant}/Checkout" """
                            }
                            stage("Build"){
                                powershell label: '', script: """Write-Output Step1 "${platform}/${variant}/Build" """
                            }
                            stage("Test"){
                                powershell label: '', script: """Write-Output Step1 "${platform}/${variant}/Test" """
                            }
                        }
                    }
                }
            }
        }
    }
}

这篇关于Jenkins声明式管道:矩阵构建轴的顺序执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆