Jenkins: Cannot define variable in pipeline stage : <p>I'm trying to create a declarative Jenkins pipeline script but having issues with simple variable declaration.</p>

<p>Here is my script:</p>

<pre><code>pipeline {
   agent none
   stages {
       stage("first") {
           def foo = "foo" // fails with "WorkflowScript: 5: Expected a step @ line 5, column 13."
           sh "echo ${foo}"
       }
   }
}
</code></pre>

<p>However, I get this error:</p>

<pre><code>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: Expected a step @ line 5, column 13.
           def foo = "foo"
           ^
</code></pre>

<p>I'm on Jenkins 2.7.4 and Pipeline 2.4.</p>
