title: echo String value from Pipeline job in Freestyle Job
body: <p>I want to print some data from my pipeline job to my freestyle job log. Therefore in my pipeline job I call the job and give some parameters:</p>
  
  <pre><code>mailBody = buf.toString()
  
  build job: 'sendEmail', parameters:
                              [
                                  string(name: 'jobName', value:env.JOB_NAME),
                                  string(name: 'buildNumber', value: env.BUILD_NUMBER),
                                  string(name: 'mailBody', value: mailBody)
                              ]
  </code></pre>
  
  <p>Inside my Freestyle job <code>sendEmail</code> I have two options. On the one hand I can call a <code>system groovy script</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/giy09.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/giy09.png" alt="enter image description here"></a></p>
  
  <p>or on the other hand a <code>windows batch</code> script:</p>
  
  <p><a href="https://i.stack.imgur.com/fk8qr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fk8qr.png" alt="enter image description here"></a></p>
  
  <p>But both of those possibilities are not working. The batch call doesnt recognize the variable and prints <code>env.JOB_NAME</code> and not the value of this variable.</p>
  
  <p>The groovy script results in the following error:</p>
  
  <pre><code>    groovy.lang.MissingMethodException: No signature of method: Script1.echo() is applicable for argument types: (java.lang.String) values: [test]
  Possible solutions: each(groovy.lang.Closure), getAt(java.lang.String), wait(), run(), run(), find()
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:81)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      at Script1.run(Script1.groovy:1)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:663)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:650)
      at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:118)
      at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:74)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      at hudson.model.Build$BuildExecution.build(Build.java:205)
      at hudson.model.Build$BuildExecution.doRun(Build.java:162)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      at hudson.model.Run.execute(Run.java:1728)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:404)
  </code></pre>
  
  <p>EDIT: After changing <code>echo</code> to <code>println</code> I am able to display values in my freestyle jobs build. But there seems to be something wrong in giving my parameters. The commmand <code>println $CHANGE_AUTHOR_EMAIL</code>, <code>println $jobName</code>, <code>println $buildNumber</code> and <code>println $mailBody</code> are resulting in the follwoing error: </p>
  
  <pre><code>groovy.lang.MissingPropertyException: No such property: $jobName for class: Script1
  </code></pre>