In my build yaml pipeline, I have a step.bash to connect to isql and run a select query. I have a requirement to fail/exit the step in case of any issue in isql and retry 2nd time.
However, Azure devops is marking step.bash as success and skipping the 2nd retry.
Is there anyway to fail the bash.step forcefully?
I tried RAISEERROR and azure devops logging commands inside the isql but no luck.
here's the step:
steps:
- bash: |
isql -U ${{ User }} -P ${{ Password }} -S ${{ Server }} -D ${{ Database }} <<-EOSQL
USE master
GO
Select * from table (If this query fails with error code 102)
IF @@error = 102
RAISERROR 17001 "Unable to login"
GO
EOSQL
echo "##vso[task.setvariable variable=dataset]ok"
displayName: Test dataset
enabled: true
condition: ne(variables['dataset'], 'ok')
continueOnError: true
exit 1
will force the task to fail.I write a demo:
Result:
So put it in the place where you want to make the task fail.