【问题标题】:How can I run a maven build in a cycle in jenkins?如何在詹金斯的循环中运行 Maven 构建?
【发布时间】:2021-10-22 16:09:18
【问题描述】:

我在 Jenkins 中有一个在 windows 代理中运行的简单 maven 作业,我总共有 50 个 windows 代理必须在其中执行脚本,问题是我必须手动执行,这意味着每当我构建一个作业并终止,然后我必须重建作业并更改上次运行的代理(参见屏幕截图),例如,job1 在代理 windows01 上运行,作业结束它必须在代理 windows02、windows03 等上运行,但是我想以自动方式而不是手动方式执行此操作。

【问题讨论】:

    标签: maven jenkins continuous-integration jenkins-pipeline


    【解决方案1】:

    你可以使用matrix:

    pipeline {
        agent none
    
        stages {
            stage('Agent matrix') {
                matrix {
                    axes {
                        axis {
                            name 'agent'
                            values 'windows01', 'windows02', 'windows03' // , ...
                        }
                    }
                    stages {
                        stage('Run') {
                            steps {
                                node( "$agent" ) {
                                    sh "echo Running on $agent..."
                                }
                            }
                        } // stage 'Run'
                    }
                } // matrix
            } // stage 'Agent matrix'
        }
    }
    

    【讨论】:

    猜你喜欢
    • 2018-04-08
    • 2014-09-19
    • 2015-01-29
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 2020-07-04
    相关资源
    最近更新 更多