【问题标题】:Jenkinsfile Declarative Pipeline - no such property pipeline classJenkinsfile 声明式管道 - 没有这样的属性管道类
【发布时间】:2018-09-05 05:40:40
【问题描述】:

我在 Jenkins 上创建了一个基本的声明式管道。当我运行构建时,它会吐出以下错误

groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding
    at groovy.lang.Binding.getVariable(Binding.java:63)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:130)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
    at WorkflowScript.run(WorkflowScript:2)
    at ___cps.transform___(Native Method)

Jenkins 服务器默认使用最新版本的默认插件。 Jenkinsfile如下所示

pipeline {
  agent any

   stages {
      stage('Sample Stage') {
          steps {
              sh '''
                ls
              '''
          }
      }
   }
}

当 Jenkins 读取 Jenkinsfile 时,pipeline 块似乎失败了,这在我看来 Jenkinsfile 相当混乱。

【问题讨论】:

标签: jenkins groovy jenkins-pipeline jenkins-declarative-pipeline


【解决方案1】:

似乎 Script Security Plugin 1.45 破坏了所有管道代码

【讨论】:

    【解决方案2】:

    这是因为您在沙盒模式下运行脚本。管道之类的功能不会在那里发布。 Script Security Plugin 版本 1.44 之前它已脱离沙盒。

    如果您希望运行单分支管道 - 只需取消标记作业设置页面底部的“使用 Groovy Sandbox”即可。 如果您使用的是多分支管道,那么您可能唯一的方法就是降级插件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2019-03-18
      • 2021-05-06
      • 1970-01-01
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      相关资源
      最近更新 更多