Reputation: 5082
How to use a bash script in the condition?
- bash: export PYTHONPATH="src/"
condition: succeeded(fileExists('./src/'))
displayName: Add src/ Path if Exists
condition: succeeded(fileExists('./src/'))
this seems not working, it shown the following error message below:
##[error]Unrecognized value: 'fileExists'.
Upvotes: 0
Views: 5974
Reputation: 41545
The conditions not works like that, you can check variables values there, check the docs.
So, if you want to check if file exist you need to add another script task that check if the file exist, if yes set a variable, than use this variable in the conditions.
Something like this:
- bash: |
if [ -f /tmp/foo.txt ]; then
echo "##vso[task.setvariable variable=fileExist]true"
fi
- bash: export PYTHONPATH="src/"
condition: and(succeeded(), eq(variables['fileExist'], 'true'))
Upvotes: 3