在步骤中找不到这样的 DSL 方法“管道”

use*_*360 5 groovy jenkins jenkins-pipeline

对于 Jenkins 中的声明性管道脚本,我不断收到此错误。

No such DSL method 'pipeline' found among steps
Run Code Online (Sandbox Code Playgroud)

我的脚本是这样的

pipeline {
    agent any
    stages {
        stage('Example Build') {
            steps {
                echo 'Hello World'
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我有 Jenkins 版本 2.19.4。希望我已经安装了所有必需的插件。为什么我会收到此异常?

unc*_*all 1

我认为您已经安装了最新的插件 1.2。我遇到了同样的问题,在将管道:模型定义升级到1.2后,我的管道停止工作。我无法降级插件(这破坏了一切)并被迫从 2.46.1 升级到 2.73.1,只有在此之后我才能再次运行管道。

不管怎样,我建议升级,因为在 2.46 中由于某种原因对我不起作用的其他代码现在可以工作了。