Home > Blockchain >  Azure devops Bash IF statement
Azure devops Bash IF statement

Time:03-29

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":

enter image description here

Can you clarify, what I'm doing wrong?

CodePudding user response:

In bash, $(command) executes command and substitutes with its output. You likely want ${variable}, which substitutes with the contents of the variable.

  • Related