Azure devops Bash IF 语句
Azure devops Bash IF statement
我在 bash 任务中有一个简单的 bash if 语句:
- 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
并且如果 $TEST_GREP 变量值等于@integration 运行 命令“npm 运行 cy:run”。但它总是转到 else 和 运行s "npm 运行 cy:parallel":
你能澄清一下,我做错了什么吗?
在 bash
中,$(command)
执行 command
并替换为它的输出。您可能需要 ${variable}
,它替换为变量的内容。
我在 bash 任务中有一个简单的 bash if 语句:
- 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
并且如果 $TEST_GREP 变量值等于@integration 运行 命令“npm 运行 cy:run”。但它总是转到 else 和 运行s "npm 运行 cy:parallel":
你能澄清一下,我做错了什么吗?
在 bash
中,$(command)
执行 command
并替换为它的输出。您可能需要 ${variable}
,它替换为变量的内容。