更改/排序或优先考虑声明性 Jenkins 管道中的构建队列

问题描述

我想要的:

我想在我的 Jenkins 文件(声明性管道)中更改/排序构建队列。实际上,我想在我的构建中优先考虑。

我熟悉以下插件:

我的问题描述:

我的流水线在更多执行器(更多标签)上运行。 TRIGGERS 标签不受限制,因此可以在其上运行许多构建(例如:100)。 MAIN 标签是有限的,只有一些构建可以在其上运行(例如:10)。因此,如果我在 TRIGGERS 标签上有 30 个构建,那么队列中将有 20 个构建(等待免费执行程序)。我有一个条件,如果这个条件是 True,构建应该作为 Prio1 处理。这意味着“重要”构建应该是队列中的第一个。所以我想优先构建 MAIN 标签(更改默认的 FIFO 方式)。

示例代码:

pipeline {
    agent { label 'TRIGGERS' }  // Many builds are possible (Eg.: 100).
    stages{
        stage('Pre-preparation'){
            script {
                echo "Running Pre-preparation on '${env.NODE_NAME}' node." // Run on TRIGGER
                if(env.IMPORTANT){
                    echo "This build should be the PRIO 1 (Not waiting previous build in queue)!"
                }
            }
        }
        stage('Build activities on MAIN'){
            // If there isn't free executor the builds are waiting here for free executor.
            // One-by-one,FIFO way. I want to change that mechanism!
            agent { label "MAIN" }  // Some builds are possible (Eg.: 10).
            stages{
                stage('Preparation 1'){
                    steps {
                        script {
                            echo "Running preparation 1 on '${env.NODE_NAME}' node." // Run on MAIN
                        }
                    }
                }
                stage('Preparation 2'){
                    steps {
                        script {
                            echo "Running preparation 2 on '${env.NODE_NAME}' node." // Run on MAIN
                        }
                    }
                }
            }
        }
    }
}

我的问题:

  • 如何更改构建队列的顺序(更改默认的 FIFO 方式)?
  • 如何为 MAIN 标签确定构建的优先级?

注意:

  • 只有声明式管道兼容解决方案是可能的!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...