Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45054

Getting MissingPropertyException when using binding in groovy scripts

XMLWordPrintable

       We have a task to read the particular string from current job console output and send in mail.

      I tried the below code to achieve this. This is written in Pipeline flow jenkinsfile from git.

      import java.*
      import java.lang.*
      import hudson.*
      import hudson.model.*
      import jenkins.model.Jenkins

      node() {

      def binding = getBinding()
      def manager = binding.getVariable("manager")
      def log = manager.build.logFile.text
      echo "${log}"
      }

      Always getting the below error.

      groovy.lang.MissingPropertyException: No such property: manager for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63)
      at groovy.lang.Binding$getVariable.call(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
       
       Detailed error are attached.

      Jenkins version 2.19.1

            wolfs Stefan Wolf
            jayaram_s jayaram s
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: