I am using a repository variable to store a patch version number for a certain branch. In my pipeline script, I use the Bitbucket API to get the value of the variable, increment it, and update the value of the variable. However, if I attempt to use the variable after that point in the script, it seems to retain its old value.
```
script:
# Get value of VERSION_NUM from BitBucket API and assign it to VERSION_NUM_NEW
- VERSION_NUM_NEW=$( curl -X GET -u "<username>":"<password>" --url 'https://api.bitbucket.org/2.0/repositories/<username>/<reposlug>/pipelines_config/variables/%7B<uuid>%7D' | jq -r .value )
- echo $VERSION_NUM_NEW # Value is 2
- echo ${VERSION_NUM} # Value is 2
# Increment VERSION_NUM_NEW
- ((VERSION_NUM++))
- echo $VERSION_NUM_NEW # Value is 3
- echo ${VERSION_NUM} # Value is 2
# Use BitBucket API to update VERSION_NUM_1_12 to new version number
- curl -vX PUT -u "<username>":"<password>" --url 'https://api.bitbucket.org/2.0/repositories/<username>/<reposlug>/pipelines_config/variables/%7B<uuid>%7D' -H 'Content-Type:application/json' -d "{\"key\":\"VERSION_NUM\",\"value\":\"$VERSION_NUM_NEW\"}"
- echo $VERSION_NUM_NEW # Value is 3
- echo ${VERSION_NUM} # Value is still 2! What??
```
Later, when I log into Bitbucket to check the value of VERSION_NUM, it has indeed been updated as I expect. It just seems that inside the script, it somehow retains its old value.
I have a workaround, but it bothers me that I can't seem to get the correct value of my variable while in the script. Am I doing something wrong?