Vasyl Stepulo
Vasyl Stepulo

Reputation: 1603

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

enter image description here

Can you clarify, what I'm doing wrong?

Upvotes: 0

Views: 1748

Answers (1)

Amadan
Amadan

Reputation: 198334

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

Upvotes: 1

Related Questions