title: Jenkins : Report results of intermediate [windows batch] build steps in email body
body: <p>As part of a Jenkins build process we run a couple Windows batch scripts and would like to report some information about these intermediate steps in the email that gets send out by Jenkins at the end.</p>
  
  <p>I thought a simple approach would be to set a Windows environment variable in the batch step and we managed to do so using PowerShell as in:</p>
  
  <pre><code>powershell.exe -Command "&amp; {[Environment]::SetEnvironmentVariable('ThisIsATest', 'TestValue', 'Machine')}"
  </code></pre>
  
  <p>When executed in a "Execute Windows batch command" build step this correctly sets the environment variable "eventually". By that I mean if I remote into the build server I can verify that the value was created / modified as expected during each build.</p>
  
  <p>However, attempting to use the value in the "Editable Email Notification" step under "Post-build Actions" by adding</p>
  
  <pre><code>Our test value: ${ENV, var="ThisIsATest"}
  </code></pre>
  
  <p>to the "Default Content" section does not give the correct result. Using</p>
  
  <pre><code>Print full environment: ${ENV}
  </code></pre>
  
  <p>also shows that the value has <em>??not yet??</em> been created.</p>
  
  <p>Even stranger is that multiple runs do not pick up the environment variable in question at all - even though I can clearly see it in the remote session (and track changes to it etc.).</p>
  
  <p>Questions:</p>
  
  <ul>
  <li><p>Would there be other ways of achieving our goal:</p>
  
  <p>"Report general success/failure when compile/unit tests where OK/failed but also report additional info from intermediate steps in the email body"?</p></li>
  <li><p>Or maybe explain the <em>odd</em> (at least to me) behavior with regards to the email plugin not picking up environment variables that one would expect it to? (To maybe give some new ideas on where to look for workarounds)</p></li>
  </ul>
  
  <p>Thanks for taking the time to read this. As always, any advice is appreciated.</p>
  
  <p>-T</p>