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

MissingPropertyException: $DEFAULT_CONTENT is not available in declarative pipeline.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • email-ext-plugin
    • None

      $DEFAULT_CONTENT is not available in jenkins declarative pipeline. Attempt to access it

       

      pipeline {
          agent any
          stages {
              stage('one') {
                  agent any
                  steps {
                      script {
                          println 'Hello world'
                      }
                  }
              }
          }
          post {
              always {
                  println 'xxxxxxxxxxxxxxxxxxxxxxxxxx'    
                  emailext body: """
          		    <p><b>Build Initiated by test</b> </p>
                      <p>${DEFAULT_CONTENT}</p>
                      <p></p>
                      <p><a href="HOST">HOST</a></p>
              """,
                  subject: '$DEFAULT_SUBJECT',
                  to: "srb@gmail.com"
              }
          }
      }
      

      gives the follow error(line number are not correct as code omitted for brevity):

      groovy.lang.MissingPropertyException: No such property: DEFAULT_CONTENT for class: WorkflowScript
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
      	at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:290)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:68)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:348)
      	at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
      	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
      	at WorkflowScript.run(WorkflowScript:30)
      

            davidvanlaatum David van Laatum
            saurabhsp Saurabh Tripathi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: