'Azure devops Bash IF statement
I have a simple bash if statement in the bash task:
- task: Bash@3
displayName: Run tests
inputs:
targetType: 'inline'
script: |
pwd
echo TEST_GREP - "$TEST_GREP"
if [ "$(TEST_GREP)" -eq "@integration" ]
then
echo 'npm run cy:run'
npm run cy:run
else
echo 'npm run cy:parallel'
npm run cy:parallel
fi
And if $TEST_GREP variable value equal to @integration run command "npm run cy:run". But it always goes to else and runs "npm run cy:parallel":
Can you clarify, what I'm doing wrong?
Solution 1:[1]
In bash, $(command) executes command and substitutes with its output. You likely want ${variable}, which substitutes with the contents of the variable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amadan |

