title: How can I set a build variable in Azure DevOps with Bash?
body: <p>I'm using the below to pull the version from my package.json file and set it to one of my build variables, <code>Version</code>.</p>
  
  <pre><code># successfully retrieves and prints the version to console
  ver=$(node -e "console.log(require('./package.json').version)")
  echo "Version: $ver"
  
  # does jack squat
  # even trying to hard-code something in place of $ver doesn't set the variable
  echo "##vso[task.setvariable variable=Version]$ver"
  echo "Version: $(Version)"
  </code></pre>
  
  <p>I've tried using <code>ver</code> and <code>$(ver)</code> instead of <code>$ver</code>, none work as the console prints a blank for <code>$(Version)</code> in all cases (it's empty to begin with). If I hard-code <code>Version</code>, it prints fine, so it's not the printing or the retrieving, it's the setting that's the issue. I've based my script on MS' example, </p>
  
  <p><code>echo "##vso[task.setvariable variable=sauce]crushed tomatoes"</code></p>
  
  <p>Our build server is in a Windows environment. </p>