You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins BlueOcean并行阶段能否默认隐藏,点击后展开子阶段?

解决Jenkins BlueOcean中默认隐藏并行子阶段的问题

BlueOcean目前没有原生全局设置来默认折叠并行阶段的子阶段,但你可以通过调整Jenkinsfile的流水线结构,实现单个并行阶段的默认隐藏(点击后展开)。核心思路是把目标并行逻辑包装在一个外层stage中,让BlueOcean将这个外层阶段识别为可折叠的父节点。

具体实现步骤

  • 给需要隐藏子阶段的并行逻辑套一个外层stage(比如你的“Browser tests”)
  • 在该外层stage的steps里用script块包裹parallel代码块
  • 将原来并行子阶段的步骤迁移到parallel的闭包中

代码示例

原流水线结构(默认展开并行子阶段)

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building application...'
      }
    }
    stage('Browser tests') {
      parallel {
        stage('Chrome') {
          steps {
            echo 'Running Chrome tests...'
            // 这里是Chrome测试的具体步骤
          }
        }
        stage('Firefox') {
          steps {
            echo 'Running Firefox tests...'
          }
        }
        stage('Safari') {
          steps {
            echo 'Running Safari tests...'
          }
        }
      }
    }
  }
}

修改后的结构(默认隐藏并行子阶段)

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building application...'
      }
    }
    stage('Browser tests') {
      steps {
        script {
          parallel(
            'Chrome': {
              echo 'Running Chrome tests...'
              // 迁移原Chrome阶段的所有步骤到这里
            },
            'Firefox': {
              echo 'Running Firefox tests...'
            },
            'Safari': {
              echo 'Running Safari tests...'
            }
          )
        }
      }
    }
  }
}

效果说明

修改后,BlueOcean的流水线视图中会默认只显示“Browser tests”这个顶层阶段,点击该阶段的节点后,才会展开显示Chrome、Firefox、Safari这些并行子任务的执行详情和状态。如果需要对多个并行阶段应用该效果,只需对每个目标并行阶段重复上述结构调整即可。

内容的提问来源于stack exchange,提问作者J_Quinn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 14:09:56