title: Bamboo: Access script variable in subsequent maven task
body: <p>I have seen many posts where people asking to access Bamboo variables in script but this is not about that. </p>
  
  <p>I am defining a variable in Shell Script task, as below, and then I would like to access that variable in the subsequent maven task.</p>
  
  <pre><code>#!/bin/sh
  currentBuildNumber=${bamboo.buildNumber}
  toSubtract=1
  newVersion=$(( currentBuildNumber - toSubtract ))
  echo "Value of newVersion: ${newVersion}"
  </code></pre>
  
  <p>This one goes perfectly fine. However I have a subsequent maven 3 task where I try to access this variable by typing <code>${newVersion}</code> I get below error</p>
  
  <pre><code>error   07-Jun-2019 14:12:20    Exception in thread "main" java.lang.StackOverflowError
  simple  07-Jun-2019 14:12:21    Failing task since return code of [mvn --batch-mode -Djava.io.tmpdir=/tmp versions:set -DnewVersion=1.0.${newVersion}] was 1 while expected 0
  </code></pre>
  
  <p>Basically, I would like to automate the version number of the built jar files just by using ${bamboo.buildNumber} and subtracting some number so that I won't have to enter the new version number every time I run a build.</p>
  
  <p>Appreciate your help... thanks,</p>
  
  <p>EDIT: I posted the same question on Atlassian forum too... I will update this post when I get an answer there... <a href="https://community.atlassian.com/t5/Bamboo-questions/Bamboo-Access-script-variable-in-subsequent-maven-task/qaq-p/1104334" rel="nofollow noreferrer">https://community.atlassian.com/t5/Bamboo-questions/Bamboo-Access-script-variable-in-subsequent-maven-task/qaq-p/1104334</a></p>