简体   繁体   English

groovy.lang.MissingPropertyException:没有此类属性:class 的 ERROR_MESSAGE:groovy.lang.Binding

[英]groovy.lang.MissingPropertyException: No such property: ERROR_MESSAGE for class: groovy.lang.Binding

I know this issue has been asked quite a number of times but the reasons are always different for occurrence of this hence asking again.我知道这个问题已经被问过很多次了,但是发生这种情况的原因总是不同的,因此再次询问。

I recently upgraded my jenkins from 2.270 to 2.278 version.我最近将我的 jenkins 从 2.270 升级到了 2.278 版本。

After the upgrade when I tried running one of the pipelines I got the following error and the pipeline failed.升级后,当我尝试运行其中一个管道时,出现以下错误并且管道失败。

groovy.lang.MissingPropertyException: No such property: ERROR_MESSAGE for class: groovy.lang.Binding groovy.lang.MissingPropertyException:没有此类属性:class 的 ERROR_MESSAGE:groovy.lang.Binding

The code snipplet where it points to look like this.它指向的代码片段看起来像这样。

   def <func2>(body) {

      <some code>
      stages {
          stage('Initialise') {
            steps {
                buildName "${JOB_NAME}#${BUILD_NUMBER}"
                script{
                    if (env.RELEASE == "1.0"){
                        env.ERROR_MESSAGE = "Please provide RELEASE"
                        currentBuild.result = 'FAILURE'
                        return
                    }
                }
            }
           post {
                    unsuccessful {
                        notifySlack(
                            **message: "Deploy Initialise failed: ${ERROR_MESSAGE}",**
                            channel:"${slackDeployChannel}")
                            script{
                                env.DEPLOY = 'no'
                            }
                    }
            }
        }

and one more place the env.ERROR_MESSAGE is being called还有一个地方 env.ERROR_MESSAGE 被调用

def <func1>(arguments) {
  try{
       <SOME CODE>
       return 0
     }
     catch (Exception e) {
       env.ERROR_MESSAGE = e.getMessage()
       return 0
     }
    }

both func1 and func2 are separate functions being called separately. func1 和 func2 都是单独调用的单独函数。 Not sure if env.ERROR_MESSAGE is being initialised or not.不确定 env.ERROR_MESSAGE 是否正在初始化。

Any leads would be appreciated.任何线索将不胜感激。

Cheers干杯

It's failing while groovy parsing "Deploy Initialise failed: ${ERROR_MESSAGE}" as the scope of initializing ENV variable is limited.当 groovy 解析"Deploy Initialise failed: ${ERROR_MESSAGE}"时失败,因为初始化 ENV 变量的 scope 是有限的。

It could be something like this:它可能是这样的:

define a variable and get it to assign and used where ever you want.定义一个变量并让它在你想要的任何地方分配和使用。

def errorMessage
def <func2>(body) {

      <some code>
      stages {
          stage('Initialise') {
            steps {
                buildName "${JOB_NAME}#${BUILD_NUMBER}"
                script{
                    if (env.RELEASE == "1.0"){
                        errorMessage = "Please provide RELEASE"
                        currentBuild.result = 'FAILURE'
                        return
                    }
                }
            }
           post {
                    unsuccessful {
                        notifySlack(
                            **message: "Deploy Initialise failed: ${errorMessage}",**
                            channel:"${slackDeployChannel}")
                            script{
                                env.DEPLOY = 'no'
                            }
                    }
            }
        }
    
def <func1>(arguments) {
  try{
       <SOME CODE>
       return 0
     }
     catch (Exception e) {
       errorMessage = e.getMessage()
       return 0
     }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 groovy.lang.MissingPropertyException:没有这样的属性:类的脚本:groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: script for class: groovy.lang.Binding groovy.lang.MissingPropertyException:没有这样的属性:class 的 sh:groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: sh for class: groovy.lang.Binding 詹金斯 Android groovy.lang.MissingPropertyException: 没有这样的属性: 类的 HOME: groovy.lang.Binding - Jenkins Android groovy.lang.MissingPropertyException: No such property: HOME for class: groovy.lang.Binding groovy.lang.MissingPropertyException:否此类属性:类groovy.lang.Binding的管道 - groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding groovy.lang.MissingPropertyException:没有此类属性:类的节点:groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: node for class: groovy.lang.Binding groovy.lang.MissingPropertyException: 没有这样的属性: jenkins for class: groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: jenkins for class: groovy.lang.Binding groovy.lang.MissingPropertyException:无此类属性:类别:groovy.lang.Binding的kubernetes-当变量为空时 - groovy.lang.MissingPropertyException: No such property: kubernetes for class: groovy.lang.Binding - when variable is empty groovy.lang.MissingPropertyException: 没有这样的属性: buildJobArray for class: groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding 获取 groovy.lang.MissingPropertyException: No such property: datepart for class: groovy.lang.Binding - Getting groovy.lang.MissingPropertyException: No such property: datepart for class: groovy.lang.Binding 发生异常:groovy.lang.MissingPropertyException:没有这样的属性:类的内容:groovy.lang.Binding - Exception occurred: groovy.lang.MissingPropertyException: No such property: content for class: groovy.lang.Binding
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM