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

MissingPropertyException: $DEFAULT_CONTENT is not available in declarative pipeline.

    Details

    • Similar Issues:

      Description

      $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)
      

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          Switch to triple single quotes

          emailext body: '''
              		    <p><b>Build Initiated by test</b> </p>
                          <p>${DEFAULT_CONTENT}</p>
                          <p></p>
                          <p><a href="HOST">HOST</a></p>
                  ''',
          

          This will stop groovy from trying to resolve the variable and let email-ext do it during it's variable replacement.

          Show
          slide_o_mix Alex Earl added a comment - Switch to triple single quotes emailext body: ''' <p><b>Build Initiated by test</b> </p> <p>${DEFAULT_CONTENT}</p> <p></p> <p><a href= "HOST" >HOST</a></p> ''', This will stop groovy from trying to resolve the variable and let email-ext do it during it's variable replacement.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: