在步骤之间找不到这样的DSL方法“管道"

在步骤之间找不到这样的DSL方法“管道

问题描述:

在詹金斯的声明式管道脚本中,我不断收到此错误.

I keep getting this error for the declarative pipeline script in Jenkins.

No such DSL method 'pipeline' found among steps

我的脚本就是这样

pipeline {
    agent any
    stages {
        stage('Example Build') {
            steps {
                echo 'Hello World'
            }
        }
    }
}

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

I have Jenkins version 2.19.4. Hopefully i have installed all the required plugins. Why do i get this exception ?

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

I think you have installed the latest plugins, 1.2. I had the same issue that after I upgraded the Pipeline: Model Definition to 1.2 my pipelines stopped working. I was unable to downgrade the plugins (this broke evertyhing) and was forced to upgrade from 2.46.1 to 2.73.1, only after this I was able to run the pipelines again.

无论如何,我建议升级,因为2.46中由于某种原因对我不起作用的其他代码现在正在起作用.

Anyway, I would recommend to upgrade as other codes that were not working for me for some reason in 2.46 are now working.