I want to use a counter to have unique build numbers in case my version string has not changed.
This is my config:
- task: Bash@3
name: GetSemVer
displayName: Get semantic version
inputs:
targetType: 'inline'
script: |
SEMVER=$(./gradlew printVersion | grep 'Version: ' | awk -F' ' '{print $2}')
echo "##vso[task.setvariable variable=semver;isOutput=true]$SEMVER"
BUILDINCREMENT=$[counter('semver', 0)]
BUILDVERSION=$SEMVER$optionalBuildTag-$BUILDINCREMENT
echo "##vso[build.updatebuildnumber]$BUILDVERSION"
I want to get a version like this:
1.0.0-beta.2+029.sha.16177d4-1
But I get this error:
/home/vsts/work/_temp/7388d9ae-e885-4bcb-b6a7-4226978a77d7.sh: line 3: counter('semver', 0): syntax error in expression (error token is "('semver', 0)")
Async Command Start: Update Build Number
Update build number to 1.0.0-beta.2+029.sha.16177d4- for build 6742
Async Command End: Update Build Number
The counter suffix is missing from the build-number.
$[counter]and variables defined during a pipeline's run.