Jenkins 'agent: none' 相当于脚本管道的轻量级执行器

Jenkins 'agent: none' lightweight executor equivalent with scripted pipeline

使用 Jenkins 声明性语法,运行 可以在没有顶级代理的情况下进行并行阶段。这最终消耗了两个执行者,因为顶级代理被标记为 'none':

pipeline {
    agent none
    stages {
        stage('Run on parallel nodes') {
            parallel {
                stage('Do one thing') {
                    agent any
                    steps {
                        ...
                    }
                stage('Do another thing') {
                    agent any
                    steps {
                        ...
                    }
                }
            }
        }
    }
}

对于需要顶级 'node' 元素的脚本化管道,这似乎是不可能的。这最终消耗了三个执行者,即使只有两个执行者在做真正的工作:

node {
  stage('Run on parallel nodes') {
    parallel ([
      'Do one thing': {
          node() {
            ...
          }
      },
      'Do another thing': {
          node() {
              ...
          }
      }
    ])
  }
}

'lightweight' 顶级执行器是否可以使用脚本化管道?

脚本化管道不需要顶级 node 分配。这是错误的,可以忽略不计。