不推荐使用不带块参数的“阶段”步骤

Using the ‘stage’ step without a block argument is deprecated

在构建 Jenkins 管道作业(Jenkins 版本 2.7.4)时,我收到此警告:

Using the ‘stage’ step without a block argument is deprecated

我该如何解决?

管道脚本片段:

stage 'Workspace Cleanup'
deleteDir()

从 Jenkins 管道阶段步骤 doc:

An older, deprecated mode of this step did not take a block argument...

为了删除警告,只需添加一个块参数:

stage('Stage Name') {
   // some block
}

您还可以使用 Snippet Generator 生成阶段步骤。

此步骤的旧已弃用模式未采用块参数,并接受并发参数

所以我猜你的管道块中没有 stage。 只需像这样放置舞台块:

stage "stage name" {
   // some block
}

stage "stage name"
//some block