显示加载的脚本管道中的阶段

Showing stages in loaded scripted pipeline

我想将一个特定的管道集成到一个更通用的管道中。通用的解析电子邮件通知并检查来自特定 SCM 的项目。此时它 运行 是在该项目中找到的 Jenkinsfile。 这两个都是脚本化管道。

generic.jenkinsfile:

node {
  stage('Initial') {
      echo 'Checking for new RRs and creating build sandbox'
  }

  stage('Calling specific') {
      def jen = load "../specific.jenkinsfile"
  }

  stage('Cleanup') {
      echo 'running cleanup'
  }
}

specific.jenkinsfile:

node() {
  stage('Build') {
      echo 'Build ...'          
  }
  stage('Flash ') {
      echo 'Flash ...'          
  }
  stage('Test  ') {    
      echo 'Test  ...'    
  }
}

specific.jenkinsfile 阶段中的步骤执行 运行 并打印这些步骤。 问题是特定 Jenkinsfile 中的阶段不会在 BlueOcean Web 界面的构建概览页面上显示为单独的阶段。相反,调用特定 会累积 load 步骤 returns 之后的所有步骤。 (虽然 load 是 运行,但所有阶段都是 "expanded" 并排的。)这不会发生在经典界面上。也许这是设计决定?

如何才能像在经典站点上一样在 BlueOcean 中显示所有展开的内容?

解决方案比我预期的要简单。

我从 load 步骤中删除了 stage('Calling specific') {},从 specific.jenkinsfile 中删除了 node {}。现在可视化效果符合预期。

# scripted pipeline
node {
  stage('Initial') {
    echo 'Checking for new RRs and creating build sandbox'
  }

  def jen = load "../specific.jenkinsfile"

  stage('Cleanup') {
    echo 'running cleanup'
  }
}